codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  how to test user input radio button after submit and back button  hermy at 23:41 on Wednesday, May 17, 2006
 

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>


  Re: how to test user input radio button after submit and back button  hermy at 00:40 on Thursday, May 18, 2006
 

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>









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: problem with Exception
•  Re: Turning java class into application
•  Re: this is weird
•  Server Name or Address could not be resolved?
•  Re: How can I read ASCII data file in C++
•  Sending automated emails
•  Re: How to kill framesets
•  What is This?
•  onKeyPress - calling a javascript function , which is showing error.


Recent Articles
What is a pointer in C?
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net


© Copyright codetoad.com 2001-2006