SlideShare a Scribd company logo
Ring Documentation, Release 1.7
49.14 HTML Lists
The next example print a list contains numbers from 1 to 10
Then print a list from Ring List.
Finally we have a list of buttons and when we press on a button we get a message contains the clicked button number.
To start the list we uses the ulstart() function.
To end the list we uses the ulend() function.
We uses listart() and liend() to determine the list item.
#!ring -cgi
Load "weblib.ring"
Import System.Web
Func Main
New Page
{
ulstart([])
for x = 1 to 10
listart([])
text(x)
liend()
next
ulend()
list2ul(["one","two","three","four","five"])
ulstart([])
for x = 1 to 10
listart([])
49.14. HTML Lists 422
Ring Documentation, Release 1.7
cFuncName = "btn"+x+"()"
button([ :onclick = cFuncName , :value = x])
script(scriptfuncalert(cFuncName,string(x)))
liend()
next
ulend()
}
Screen Shot:
49.14. HTML Lists 423
Ring Documentation, Release 1.7
49.15 HTML Tables
In this example we will learn how to generate HTML tables using the tablestart(), tableend(), rowstart(), rowend()
,headerstart(), headerend(), cellstart() and cellend() functions.
#!ring -cgi
Load "weblib.ring"
Import System.Web
Func Main
New Page
{
divstart([ :style = styledivcenter("400px","500px") ] )
style(styletable() + styletablerows("t01"))
tablestart([ :id = :t01 , :style = stylewidth("100%") ])
rowstart([])
headerstart([]) text("Number") headerend()
headerstart([]) text("square") headerend()
rowend()
for x = 1 to 10
rowstart([])
cellstart([]) text(x) cellend()
cellstart([]) text(x*x) cellend()
rowend()
next
tableend()
divend()
}
Screen Shot:
49.15. HTML Tables 424
Ring Documentation, Release 1.7
49.16 Gradient
In this example we will learn how to use the StyleGradient() function.
The function takes the style number as input (range from 1 to 60).
#!ring -cgi
Load "weblib.ring"
Import System.Web
Func Main
New Page
{
boxstart()
text("StyleGradient() Function")
boxend()
for x = 1 to 60
divstart([ :id = x , :align = "center" ,
:style = stylefloatleft() +
stylesize(string(100/60*6)+"%","50px") +
stylegradient(x) ])
h3(x)
divend()
next
}
Screen Shot:
49.16. Gradient 425
Ring Documentation, Release 1.7
49.17 Generating Pages using Objects
Instead of using functions/methods to generate HTML pages, we can use an object for each element in the page.
This choice means more beautiful code but slower.
The fastest method is to print HTML code directly, then using functions then using templates then using objects
(slower).
#!ring -cgi
Load "weblib.ring"
Import System.Web
Func Main
WebPage()
{
Title = "Using objects to create the Web Page content"
h1 { text("welcome") }
link
{
Title = "Google"
Link = "http://www.google.com"
}
div
{
id = "div1"
style = stylegradient(30) + stylesize("50%","50%")
text("Outer Div")
div
{
id = "div2"
color = "white"
backgroundcolor = "green"
width = "50%"
height = "50%"
marginleft = "5%"
margintop = "5%"
text("Inner Div")
}
}
div
{
id = "div3"
color = "black"
backgroundcolor = "silver"
width = "100%"
height = "100%"
text("Form")
form
{
method = "POST"
Action = "helloworld.ring"
Table
{
style = stylewidth("100%") + stylegradient(24)
TR
{
TD { WIDTH="10%" text("Name : " ) }
49.17. Generating Pages using Objects 426
Ring Documentation, Release 1.7
TD { Input { type = "text" } }
}
TR
{
TD { WIDTH="10%" text("Email : " ) }
TD { Input { type = "text" } }
}
TR
{
TD { WIDTH="10%" text("Password : " ) }
TD { Input { type = "password" } }
}
TR
{
TD { WIDTH="10%" text("Notes") }
TD { TextArea { width="100%" rows = 10 cols = 10
text("type text here...") } }
}
TR
{
TD { WIDTH="10%" text("Gender") }
TD {
select
{
width = "100%"
option { text("Male") }
option { text("Female") }
}
}
}
TR
{
TD { WIDTH="10%" text("Role") }
TD
{
select
{
multiple = "multiple"
width = "100%"
option { text("student") }
option { text("admin") }
}
}
}
}
Input { type = "submit" value = "send" }
Image { src="upload/profile1.jpg" alt="profile"}
Input { type = "checkbox" value = "Old Member"} text("old member")
Input { type = "range" min=1 max=100}
Input { type = "number" min=1 max=100}
Input { type = "radio" color="black" name="one"
value = "one"} text("one")
}
}
div
{
color = "white"
49.17. Generating Pages using Objects 427
Ring Documentation, Release 1.7
backgroundcolor = "blue"
width = "100%"
UL
{
LI { TEXT("ONE") }
LI { TEXT("TWO") }
LI { TEXT("THREE") }
}
}
div
{
audio
{
src = "horse.ogg"
type = "audio/ogg"
}
video
{
width = 320
height = 240
src = "movie.mp4"
type = "video/mp4"
}
Input
{
type = "color"
value = "#ff0000"
onchange = "clickColor(0, -1, -1, 5)"
}
}
}
Screen Shot:
49.17. Generating Pages using Objects 428
Ring Documentation, Release 1.7
49.17. Generating Pages using Objects 429
Ring Documentation, Release 1.7
49.18 HtmlPage Class
Using this class we can create HTML documents without printing the output to the standard output
So instead of using the WebLib in Web Applications only
We can use it in Console/GUI/Mobile Applications too
Example:
load "stdlib.ring"
load "weblib.ring"
import System.Web
49.18. HtmlPage Class 430
Ring Documentation, Release 1.7
func main
mypage = new HtmlPage {
h1 { text("Customers Report") }
Table
{
style = stylewidth("100%") + stylegradient(4)
TR
{
TD { WIDTH="10%" text("Customers Count : " ) }
TD { text (100) }
}
}
Table
{
style = stylewidth("100%") + stylegradient(26)
TR
{
style = stylewidth("100%") + stylegradient(24)
TD { text("Name " ) }
TD { text("Age" ) }
TD { text("Country" ) }
TD { text("Job" ) }
TD { text("Company" ) }
}
for x = 1 to 100
TR
{
TD { text("Test" ) }
TD { text("30" ) }
TD { text("Egypt" ) }
TD { text("Sales" ) }
TD { text("Future" ) }
}
next
}
}
write("report.html",mypage.output())
49.19 Using Bootstrap Library using Functions
The next example uses the Bootstrap JavaScript Library when generating the HTML page.
#!ring -cgi
Load "weblib.ring"
Import System.Web
Func Main
new BootstrapPage {
divstart([ :class = "container" ])
divstart([ :class = "jumbotron" ])
h1("Bootstrap Page")
divend()
49.19. Using Bootstrap Library using Functions 431

More Related Content

PDF
The Ring programming language version 1.4 book - Part 12 of 30
PDF
The Ring programming language version 1.5.4 book - Part 42 of 185
PDF
The Ring programming language version 1.2 book - Part 30 of 84
PDF
A proper introduction to Elm
PDF
The Ring programming language version 1.5.3 book - Part 42 of 184
PDF
The Ring programming language version 1.5.2 book - Part 42 of 181
PDF
The Ring programming language version 1.10 book - Part 52 of 212
PDF
The Ring programming language version 1.5.2 book - Part 41 of 181
The Ring programming language version 1.4 book - Part 12 of 30
The Ring programming language version 1.5.4 book - Part 42 of 185
The Ring programming language version 1.2 book - Part 30 of 84
A proper introduction to Elm
The Ring programming language version 1.5.3 book - Part 42 of 184
The Ring programming language version 1.5.2 book - Part 42 of 181
The Ring programming language version 1.10 book - Part 52 of 212
The Ring programming language version 1.5.2 book - Part 41 of 181

What's hot (19)

PDF
The Ring programming language version 1.8 book - Part 48 of 202
PDF
The Ring programming language version 1.3 book - Part 32 of 88
PDF
PureScript & Pux
PDF
The Ring programming language version 1.2 book - Part 29 of 84
PDF
The Ring programming language version 1.5.1 book - Part 39 of 180
PDF
The Ring programming language version 1.3 book - Part 31 of 88
PDF
The Ring programming language version 1.8 book - Part 46 of 202
PDF
The Ring programming language version 1.7 book - Part 44 of 196
PDF
resume_Alexey_Zaytsev
PDF
The Ring programming language version 1.4.1 book - Part 12 of 31
PDF
The Ring programming language version 1.5.4 book - Part 40 of 185
PDF
Custom LINQ Providers
PDF
ゼロから始めるScala文法
PDF
The Ring programming language version 1.5.2 book - Part 40 of 181
PDF
The Ring programming language version 1.6 book - Part 43 of 189
PDF
The Ring programming language version 1.9 book - Part 51 of 210
ODP
Graphics & Animation with HTML5
PDF
The Ring programming language version 1.5.1 book - Part 41 of 180
PDF
関数プログラミングことはじめ revival
The Ring programming language version 1.8 book - Part 48 of 202
The Ring programming language version 1.3 book - Part 32 of 88
PureScript & Pux
The Ring programming language version 1.2 book - Part 29 of 84
The Ring programming language version 1.5.1 book - Part 39 of 180
The Ring programming language version 1.3 book - Part 31 of 88
The Ring programming language version 1.8 book - Part 46 of 202
The Ring programming language version 1.7 book - Part 44 of 196
resume_Alexey_Zaytsev
The Ring programming language version 1.4.1 book - Part 12 of 31
The Ring programming language version 1.5.4 book - Part 40 of 185
Custom LINQ Providers
ゼロから始めるScala文法
The Ring programming language version 1.5.2 book - Part 40 of 181
The Ring programming language version 1.6 book - Part 43 of 189
The Ring programming language version 1.9 book - Part 51 of 210
Graphics & Animation with HTML5
The Ring programming language version 1.5.1 book - Part 41 of 180
関数プログラミングことはじめ revival
Ad

Similar to The Ring programming language version 1.7 book - Part 46 of 196 (20)

PDF
The Ring programming language version 1.6 book - Part 44 of 189
PDF
The Ring programming language version 1.5.3 book - Part 52 of 184
PDF
The Ring programming language version 1.2 book - Part 31 of 84
PDF
The Ring programming language version 1.5.4 book - Part 43 of 185
PDF
The Ring programming language version 1.6 book - Part 45 of 189
PDF
The Ring programming language version 1.10 book - Part 53 of 212
PDF
The Ring programming language version 1.5.3 book - Part 43 of 184
PDF
The Ring programming language version 1.5.3 book - Part 53 of 184
PDF
The Ring programming language version 1.9 book - Part 49 of 210
PDF
The Ring programming language version 1.5.3 book - Part 40 of 184
PDF
The Ring programming language version 1.5.4 book - Part 45 of 185
PDF
The Ring programming language version 1.3 book - Part 35 of 88
PDF
The Ring programming language version 1.10 book - Part 50 of 212
PDF
The Ring programming language version 1.5.1 book - Part 40 of 180
PDF
The Ring programming language version 1.3 book - Part 33 of 88
PDF
The Ring programming language version 1.5.2 book - Part 44 of 181
PDF
The Ring programming language version 1.9 book - Part 50 of 210
PDF
The Ring programming language version 1.8 book - Part 47 of 202
PDF
The Ring programming language version 1.5.3 book - Part 51 of 184
PDF
The Ring programming language version 1.5.3 book - Part 41 of 184
The Ring programming language version 1.6 book - Part 44 of 189
The Ring programming language version 1.5.3 book - Part 52 of 184
The Ring programming language version 1.2 book - Part 31 of 84
The Ring programming language version 1.5.4 book - Part 43 of 185
The Ring programming language version 1.6 book - Part 45 of 189
The Ring programming language version 1.10 book - Part 53 of 212
The Ring programming language version 1.5.3 book - Part 43 of 184
The Ring programming language version 1.5.3 book - Part 53 of 184
The Ring programming language version 1.9 book - Part 49 of 210
The Ring programming language version 1.5.3 book - Part 40 of 184
The Ring programming language version 1.5.4 book - Part 45 of 185
The Ring programming language version 1.3 book - Part 35 of 88
The Ring programming language version 1.10 book - Part 50 of 212
The Ring programming language version 1.5.1 book - Part 40 of 180
The Ring programming language version 1.3 book - Part 33 of 88
The Ring programming language version 1.5.2 book - Part 44 of 181
The Ring programming language version 1.9 book - Part 50 of 210
The Ring programming language version 1.8 book - Part 47 of 202
The Ring programming language version 1.5.3 book - Part 51 of 184
The Ring programming language version 1.5.3 book - Part 41 of 184
Ad

More from Mahmoud Samir Fayed (20)

PDF
The Ring programming language version 1.10 book - Part 212 of 212
PDF
The Ring programming language version 1.10 book - Part 211 of 212
PDF
The Ring programming language version 1.10 book - Part 210 of 212
PDF
The Ring programming language version 1.10 book - Part 208 of 212
PDF
The Ring programming language version 1.10 book - Part 207 of 212
PDF
The Ring programming language version 1.10 book - Part 205 of 212
PDF
The Ring programming language version 1.10 book - Part 206 of 212
PDF
The Ring programming language version 1.10 book - Part 204 of 212
PDF
The Ring programming language version 1.10 book - Part 203 of 212
PDF
The Ring programming language version 1.10 book - Part 202 of 212
PDF
The Ring programming language version 1.10 book - Part 201 of 212
PDF
The Ring programming language version 1.10 book - Part 200 of 212
PDF
The Ring programming language version 1.10 book - Part 199 of 212
PDF
The Ring programming language version 1.10 book - Part 198 of 212
PDF
The Ring programming language version 1.10 book - Part 197 of 212
PDF
The Ring programming language version 1.10 book - Part 196 of 212
PDF
The Ring programming language version 1.10 book - Part 195 of 212
PDF
The Ring programming language version 1.10 book - Part 194 of 212
PDF
The Ring programming language version 1.10 book - Part 193 of 212
PDF
The Ring programming language version 1.10 book - Part 192 of 212
The Ring programming language version 1.10 book - Part 212 of 212
The Ring programming language version 1.10 book - Part 211 of 212
The Ring programming language version 1.10 book - Part 210 of 212
The Ring programming language version 1.10 book - Part 208 of 212
The Ring programming language version 1.10 book - Part 207 of 212
The Ring programming language version 1.10 book - Part 205 of 212
The Ring programming language version 1.10 book - Part 206 of 212
The Ring programming language version 1.10 book - Part 204 of 212
The Ring programming language version 1.10 book - Part 203 of 212
The Ring programming language version 1.10 book - Part 202 of 212
The Ring programming language version 1.10 book - Part 201 of 212
The Ring programming language version 1.10 book - Part 200 of 212
The Ring programming language version 1.10 book - Part 199 of 212
The Ring programming language version 1.10 book - Part 198 of 212
The Ring programming language version 1.10 book - Part 197 of 212
The Ring programming language version 1.10 book - Part 196 of 212
The Ring programming language version 1.10 book - Part 195 of 212
The Ring programming language version 1.10 book - Part 194 of 212
The Ring programming language version 1.10 book - Part 193 of 212
The Ring programming language version 1.10 book - Part 192 of 212

Recently uploaded (20)

PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation theory and applications.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Electronic commerce courselecture one. Pdf
PPTX
Cloud computing and distributed systems.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
A Presentation on Artificial Intelligence
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Machine learning based COVID-19 study performance prediction
Encapsulation theory and applications.pdf
Network Security Unit 5.pdf for BCA BBA.
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Encapsulation_ Review paper, used for researhc scholars
Advanced methodologies resolving dimensionality complications for autism neur...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Per capita expenditure prediction using model stacking based on satellite ima...
Electronic commerce courselecture one. Pdf
Cloud computing and distributed systems.
The Rise and Fall of 3GPP – Time for a Sabbatical?
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Spectral efficient network and resource selection model in 5G networks
Dropbox Q2 2025 Financial Results & Investor Presentation
The AUB Centre for AI in Media Proposal.docx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Unlocking AI with Model Context Protocol (MCP)
A Presentation on Artificial Intelligence

The Ring programming language version 1.7 book - Part 46 of 196

  • 1. Ring Documentation, Release 1.7 49.14 HTML Lists The next example print a list contains numbers from 1 to 10 Then print a list from Ring List. Finally we have a list of buttons and when we press on a button we get a message contains the clicked button number. To start the list we uses the ulstart() function. To end the list we uses the ulend() function. We uses listart() and liend() to determine the list item. #!ring -cgi Load "weblib.ring" Import System.Web Func Main New Page { ulstart([]) for x = 1 to 10 listart([]) text(x) liend() next ulend() list2ul(["one","two","three","four","five"]) ulstart([]) for x = 1 to 10 listart([]) 49.14. HTML Lists 422
  • 2. Ring Documentation, Release 1.7 cFuncName = "btn"+x+"()" button([ :onclick = cFuncName , :value = x]) script(scriptfuncalert(cFuncName,string(x))) liend() next ulend() } Screen Shot: 49.14. HTML Lists 423
  • 3. Ring Documentation, Release 1.7 49.15 HTML Tables In this example we will learn how to generate HTML tables using the tablestart(), tableend(), rowstart(), rowend() ,headerstart(), headerend(), cellstart() and cellend() functions. #!ring -cgi Load "weblib.ring" Import System.Web Func Main New Page { divstart([ :style = styledivcenter("400px","500px") ] ) style(styletable() + styletablerows("t01")) tablestart([ :id = :t01 , :style = stylewidth("100%") ]) rowstart([]) headerstart([]) text("Number") headerend() headerstart([]) text("square") headerend() rowend() for x = 1 to 10 rowstart([]) cellstart([]) text(x) cellend() cellstart([]) text(x*x) cellend() rowend() next tableend() divend() } Screen Shot: 49.15. HTML Tables 424
  • 4. Ring Documentation, Release 1.7 49.16 Gradient In this example we will learn how to use the StyleGradient() function. The function takes the style number as input (range from 1 to 60). #!ring -cgi Load "weblib.ring" Import System.Web Func Main New Page { boxstart() text("StyleGradient() Function") boxend() for x = 1 to 60 divstart([ :id = x , :align = "center" , :style = stylefloatleft() + stylesize(string(100/60*6)+"%","50px") + stylegradient(x) ]) h3(x) divend() next } Screen Shot: 49.16. Gradient 425
  • 5. Ring Documentation, Release 1.7 49.17 Generating Pages using Objects Instead of using functions/methods to generate HTML pages, we can use an object for each element in the page. This choice means more beautiful code but slower. The fastest method is to print HTML code directly, then using functions then using templates then using objects (slower). #!ring -cgi Load "weblib.ring" Import System.Web Func Main WebPage() { Title = "Using objects to create the Web Page content" h1 { text("welcome") } link { Title = "Google" Link = "http://www.google.com" } div { id = "div1" style = stylegradient(30) + stylesize("50%","50%") text("Outer Div") div { id = "div2" color = "white" backgroundcolor = "green" width = "50%" height = "50%" marginleft = "5%" margintop = "5%" text("Inner Div") } } div { id = "div3" color = "black" backgroundcolor = "silver" width = "100%" height = "100%" text("Form") form { method = "POST" Action = "helloworld.ring" Table { style = stylewidth("100%") + stylegradient(24) TR { TD { WIDTH="10%" text("Name : " ) } 49.17. Generating Pages using Objects 426
  • 6. Ring Documentation, Release 1.7 TD { Input { type = "text" } } } TR { TD { WIDTH="10%" text("Email : " ) } TD { Input { type = "text" } } } TR { TD { WIDTH="10%" text("Password : " ) } TD { Input { type = "password" } } } TR { TD { WIDTH="10%" text("Notes") } TD { TextArea { width="100%" rows = 10 cols = 10 text("type text here...") } } } TR { TD { WIDTH="10%" text("Gender") } TD { select { width = "100%" option { text("Male") } option { text("Female") } } } } TR { TD { WIDTH="10%" text("Role") } TD { select { multiple = "multiple" width = "100%" option { text("student") } option { text("admin") } } } } } Input { type = "submit" value = "send" } Image { src="upload/profile1.jpg" alt="profile"} Input { type = "checkbox" value = "Old Member"} text("old member") Input { type = "range" min=1 max=100} Input { type = "number" min=1 max=100} Input { type = "radio" color="black" name="one" value = "one"} text("one") } } div { color = "white" 49.17. Generating Pages using Objects 427
  • 7. Ring Documentation, Release 1.7 backgroundcolor = "blue" width = "100%" UL { LI { TEXT("ONE") } LI { TEXT("TWO") } LI { TEXT("THREE") } } } div { audio { src = "horse.ogg" type = "audio/ogg" } video { width = 320 height = 240 src = "movie.mp4" type = "video/mp4" } Input { type = "color" value = "#ff0000" onchange = "clickColor(0, -1, -1, 5)" } } } Screen Shot: 49.17. Generating Pages using Objects 428
  • 8. Ring Documentation, Release 1.7 49.17. Generating Pages using Objects 429
  • 9. Ring Documentation, Release 1.7 49.18 HtmlPage Class Using this class we can create HTML documents without printing the output to the standard output So instead of using the WebLib in Web Applications only We can use it in Console/GUI/Mobile Applications too Example: load "stdlib.ring" load "weblib.ring" import System.Web 49.18. HtmlPage Class 430
  • 10. Ring Documentation, Release 1.7 func main mypage = new HtmlPage { h1 { text("Customers Report") } Table { style = stylewidth("100%") + stylegradient(4) TR { TD { WIDTH="10%" text("Customers Count : " ) } TD { text (100) } } } Table { style = stylewidth("100%") + stylegradient(26) TR { style = stylewidth("100%") + stylegradient(24) TD { text("Name " ) } TD { text("Age" ) } TD { text("Country" ) } TD { text("Job" ) } TD { text("Company" ) } } for x = 1 to 100 TR { TD { text("Test" ) } TD { text("30" ) } TD { text("Egypt" ) } TD { text("Sales" ) } TD { text("Future" ) } } next } } write("report.html",mypage.output()) 49.19 Using Bootstrap Library using Functions The next example uses the Bootstrap JavaScript Library when generating the HTML page. #!ring -cgi Load "weblib.ring" Import System.Web Func Main new BootstrapPage { divstart([ :class = "container" ]) divstart([ :class = "jumbotron" ]) h1("Bootstrap Page") divend() 49.19. Using Bootstrap Library using Functions 431