Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to pass value of selected radio button 1

Status
Not open for further replies.

PushCode

Programmer
Dec 17, 2003
573
US
I've got a set of radio buttons named 'zipit'. The value of one is yes, the other is no. I need to pass the value of whichever one the user selects. Can anyone help me with this?

Here's the code of the page in question:
Code:
<html><head>
<script language="JavaScript">
	function dosubmit(email)
	  {                
		  window.opener.doemail(email,document.frmEmail.zipit);
		  window.opener = self;
		  window.close();
	  }
</script>
<link rel="stylesheet" type="text/css" href="/default.css.cfm">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
  <form name="frmEmail" method="post">
  <tr> 
    <td colspan="2"><br>
      Email Files To: 
      <input type="text" name="email"></td>
  </tr>
  <tr> 
    <td colspan="2"><br>
      Zip Files?  &nbsp; &nbsp; &nbsp; Yes<input type="radio" name="zipit" value="yes"> &nbsp; No<input type="radio" name="zipit" value="no"></td>
  </tr>
  <tr> 
    <td colspan="2"><br><input type="button" value="Send Email" onclick="dosubmit(document.frmEmail.email.value)"></td>
  </tr>
  </form>
</table>
</body></html>
 
Figured it out on my own. Here's the working script for future reference:

<script language="JavaScript">
function dosubmit(email)
{
if (document.frmEmail.email.value == "")
{
alert("You must enter an email address.")
}
else if (!document.frmEmail.zipit[0].checked && !document.frmEmail.zipit[1].checked)
{
alert("You must select whether or not to zip the files.")
}
else if (document.frmEmail.zipit[0].checked)
{zipit = "yes"}
else if (document.frmEmail.zipit[1].checked)
{zipit = "no"}

{
window.opener.doemail(email,zipit);
window.opener = self;
window.close();
}
}
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top