How to Create a Dynamic Web Page - Completed File
(Page 4 of 4 )
Your completed text file should now look a little (well, exactly) like this:
<html>
<head>
<title>Dynamic Example</title>
<script language="VBScript">
sub people_onclick()
if people.selectedIndex="0" then
form1.details.value="Make a Selection"
else
select case people.selectedIndex
case 1
form1.details.value="1 Nowhere Street, Ghost Town, AB1 2CD"
case 2
form1.details.value="2 Unknown Lane, Gonesville, EF3 4GH"
case 3
form1.details.value="3 Invisible Avenue, Nothingshire, IJ5 6KL"
case 4
form1.details.value="4 Somewhere Road, Vancancy, MN7 8OP"
case 5
form1.details.value="5 lestways, Notknownsbury, QR9 0ST"
case 6
form1.details.value="6 Lost Court, Summerwhere, UV12 3WX"
case 7
form1.details.value="7 Nodnol Place. Nohampton, YZ45 6AB"
case 8
form1.details.value="8 Empty Square, Notthereburgh, CD7 8EF"
case 9
form1.details.value="9 Unbuilt Crescent, Guester, GH8 9IJ"
case 10
form1.details.value="10 Unfound House, Neverpool, KM27 4NO"
end select
end if
end sub
</script>
</head>
<body>
<select id=”people”>
<option>Please select</option>
<option>Mr Smith</option>
<option>Mrs Bloggs</option>
<option>Mr Doe</option>
<option>Mrs Jones</option>
<option>Mr Spencer</option>
<option>Mr Field</option>
<option>Ms Reed</option>
<option>Mr Waters</option>
<option>Mrs Frank</option>
<option>Mr Green</option>
</select>
<form id=”form1”>
<textarea rows="12" cols="60" id=”details”>The details will be displayed here</textarea>
</form>
</body>
</html>
If you wanted to add a little formatting to the text that is displayed in the textarea, you can add + chr(13) + in the value, for example:
form1.details.value="1 Nowhere Street, Ghost Town, AB1 2CD" + chr(13) + “01234 546789”
Which would then display in the textarea as:
1 Nowhere Street, Ghost Town, AB1 2CD
01234 546789
chr(13) is the ASCII code for the return key on your keyboard.
That’s all there is to it; save the file as dynamicExample.htm and open it in explorer. Have a play around to understand what the code you’ve implemented does, and congratulate yourself on making your first dynamic web page.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |