Each of the text fields above is 50 characters in length.When the user clicks the submit button, a VBScript routine should:
If errors are detected when checking items 2-4 above, display a message box and request the user re-enter the data.
After performing step 1 above AND all data edits (items 2-4 above) are OK, submit the form to:
http://www.fred.com/check.cgi
(40 points) Consider the following HTML frame structure:
This is just HTML -- the button does not work. See answer below
The value of "counter" is located in a hidden form value which is part of Frame 3. This hidden value is initially zero. When the user clicks on one of the links on Frame 1:
- the value of counter is incremented by the value shown on the link (i.e., 1,2,3,4, or 5)
- Frame 2 is then recreated with the new value of counter displayed
If the user clicks the Reset button in Frame 3, the value of counter is set to zero and Frame 2 recreated.
Answer:
Click here to see the whole thing work.
The answer is laid out in five frames:
At the top is f3371ans.htm. This htm file contain is a frameset like this:
<html>
<frameset cols="300,*">
<frame src="fframe0.htm">
<frame src="fframe2.htm">
</html>
fframe0.htm is a frameset that creates two rows:
<html>
<frameset rows="300,*">
<frame src="fframe1.htm">
<frame src="fframe3.htm">
</html>
Frame 1 (i.e., fframe1.htm) is:
<html>
<body>
<p> <p><center>FRAME 1</center>
<ol>
<li><a href="fframe1.htm" language="VBSCRIPT" onclick=
'dim a,b:
set a=top.frames(0).frames(1).document.f3form:
set b=top.frames(1):
a.counter.value=a.counter.value +1:
b.location.href="fframe2.htm":'>ADD 1 to counter</a>
<li><a href="fframe1.htm" language="VBSCRIPT" onclick=
'dim a,b:
set a=top.frames(0).frames(1).document.f3form:
set b=top.frames(1):
a.counter.value=a.counter.value +2:
b.location.href="fframe2.htm":'>ADD 2 to counter</a>
<li><a href="fframe1.htm" language="VBSCRIPT" onclick=
'dim a,b:
set a=top.frames(0).frames(1).document.f3form:
set b=top.frames(1):
a.counter.value=a.counter.value +3:
b.location.href="fframe2.htm":'>ADD 3 to counter</a>
<li><a href="fframe1.htm" language="VBSCRIPT" onclick=
'dim a,b:
set a=top.frames(0).frames(1).document.f3form:
set b=top.frames(1):
a.counter.value=a.counter.value +4:
b.location.href="fframe2.htm":'>ADD 4 to counter</a>
<li><a href="fframe1.htm" language="VBSCRIPT" onclick=
'dim a,b:
set a=top.frames(0).frames(1).document.f3form:
set b=top.frames(1):
a.counter.value=a.counter.value +5:
b.location.href="fframe2.htm":'>ADD 5 to counter</a>
</ol>
</body>
</html>
Frame 2 (i.e., fframe2.htm) is:
<html>
<head>
<script language="VBSCRIPT">
<!---
sub f2_onload
document.clear
document.open
document.write "<html><body><font size='5'><p><center>Frame 2<p>"
document.write "COUNTER = "
document.write cstr(top.frames(0).frames(1).f3form.counter.value)
document.write "</center></body></html>"
document.close
end sub
--->
</script>
</head>
<body onload="f2_onload">
</body>
</html>
Frame 3 (i.e., fframe3.htm) is:
<html>
<head>
<script language="vbscript">
<!---
sub makezero_onClick
window.document.f3form.counter.value=0
top.frames(1).location.href="fframe2.htm"
end sub
--->
</script>
</head>
<body>
<center>FRAME 3<p>
<form name="f3form">
<input type="button" value="Reset Counter to Zero" name="makezero"></center>
<input type="hidden" name="counter" value="0">
</form>
</body>
</html>