CpSc 217 - Structured and Dynamic Web Programmings
To generate pages using Javascript:
- Create the template of the page in HTML
- Design the look of the page
- Make sure the "base" is formatted correctly
- If you need multiple items that need to be determined by Javascript, simply put a few test items in.
- Try this page
- Now intersperse Javascript with HTML
- Start simple: Replace the html, head, body tags with document writes (Note: most times it is not necessary to COMPLETELY generate a page, but just parts of the page)
- Next set up variables as follows:
var FONT = "<font face=arial size=2>"
var ENDFONT = "</font>"
var SubCategoryName="hello"
var Active="True"
var MaxURLS= 4
- Using the FONT and ENDFONT variables, generate the title and the start
of the table
- Next generate the Radio button. Here's some help for this one!
document.writeln ( "<input type='radio' name='active' value='1'" );
if (Active=="True")
document.write ( "checked" );
document.write ( ">Inactive" );
document.writeln ( "<input type='radio' name='active' value='0'" );
if (Active=="False")
document.write ( "checked" )
document.write ( ">" );
- Why do you think that sometimes I use writeln instead of "write"
Partial Solution
- Continue on with the rest of the page
Getting the Picture?
- Notice that the text boxes are numbered and have a corresponding URL of some sort.
You need to use a for loop and the variable maxURLS to achieve this.
- Notice the names of the text boxes and values; these need to be generated, not hardcoded.
Almost There
- Good luck!
Final Solution