|
Hello,
I am having a problem testing the checked value of a radio button after submit and going back to the page with the back button in the browser.
The test:
if (document.form1.gift[0].checked) alert("yes is checked");
doesn't work although the user checked it.
You can see the script on http://www.hierindemarkt.nl/test
Any help is appreciated very much.
Hermy
-----------
<form name="form1" method="post" action="test.html">
Is it a gift?
<label><input name="gift" type="radio" value="yes">yes</label>
<label><input name="gift" type="radio" value="no">no</label>
<p><input type="submit" name="Submit" value="Submit"></p>
</form>
<script language="JavaScript" type="text/JavaScript">
<!--
alert("script");
if (document.form1.gift[0].checked) alert("yes is checked");
if (document.form1.gift[1].checked) alert("no is checked");
-->
</script>
|
|
|
Found the solution on an other website. Changed the script and now it works.
See http://www.hierindemarkt.nl/test/index2.html
<form name="form1" method="post" action="test.html">
Is it a gift?
<label><input name="gift" type="radio" value="yes">yes</label>
<label><input name="gift" type="radio" value="no">no</label>
<p><input type="submit" name="Submit" value="Submit">
</form>
<script language="JavaScript" type="text/JavaScript">
<!--
function test() {
if (document.form1.gift[0].checked) alert("yes is checked");
if (document.form1.gift[1].checked) alert("no is checked");
}
if( window.addEventListener ) window.addEventListener( 'load', test, false );
else if( document.addEventListener ) document.addEventListener('load' , test, false );
else if( window.attachEvent ) window.attachEvent( 'onload', test );
else {
if( window.onload ) { window.XTRonload = window.onload; }
window.onload = test;
}
-->
</script>
|
|
|
|
|
|
|
|