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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display form based on radio button selection 1

Status
Not open for further replies.

rjseals

Technical User
Nov 25, 2002
63
US
I have two different login systems login A and login B. So if possible I want to have two radio buttons that will display a login form (username and password) but send the login information to different places based on the radio that is selected. So for instance if A is selected when the user enteres their username and password it will send their information to /A/login.html or if b /B/login.html.

Thanks!
 
use the form's onsubmit handler to switch the action tag of the form depending on what was checked:
Code:
<script type="text/javascript">
function blah(theForm) {
   var radios = theForm.elements["rad"];
   if (radios[0].checked) {
      theForm.action = "./a/login.html";
   }
   else {
      theForm.action = "./b/login.html";
   }
   return true;
}
</script>
<body>
<form method="post" id="frm" onsubmit="return blah(this)" action="">
   <input type="radio" value="a" name="rad" />a<br />
   <input type="radio" value="b" name="rad" />a<br />
   <input type="text" id="txt"><br />
   <input type="submit" value="submit me">
</form>
</body>

-kaht

How much you wanna make a bet I can throw a football over them mountains?
sheepico.jpg
images
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top