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!

submit form technique 1

Status
Not open for further replies.

leahyj

MIS
May 5, 2004
107
US
Hi,

I'm trying to take the value of a radio element as the action="blah.url" of a form submital.

Any takers.

Thanks.
 
here's a quick example:
Code:
<script type="text/javascript">

function setFormAction(frm) {
   if (frm.elements["myRadio"][0].checked) {
      frm.action = frm.elements["myRadio"][0].value;
   }
   else if (frm.elements["myRadio"][1].checked) {
      frm.action = frm.elements["myRadio"][1].value;
   }
   else {
      frm.action = "";
   }
}

function whatIsMyAction(frm) {
   alert("The form action was set to (" + frm.action + ")");
   return false;
}

</script>

<form onsubmit="return whatIsMyAction(this)">
   <input type="radio" name="myRadio" value="page1.asp" /> page 1 <br />
   <input type="radio" name="myRadio" value="page2.asp" /> page 2 <br />
   <input type="submit" onclick="setFormAction(this.form)" />
</form>

-kaht

[small](All puppies have now found loving homes, thanks for all who showed interest)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top