Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Javascript Radio Button to Select Relevant Login Page

Options
  • 13-06-2007 12:23pm
    #1
    Closed Accounts Posts: 909 ✭✭✭


    Hi,

    Im not a Javascript programmer and have googled for this but I need some help.

    I currently have 2 login areas on my website - one for managers and one for players. The login page for each is different.

    I want to replace the 2 login areas with 1 single login area that has an option button to select the correct URL for the form to taget. I think I need some Javscript to change the "action=abc.php" to "action=def.php" whenever the default radio button is not selected.

    Has anyone done this before with Javascript or give a link tot his on the web?

    Many Thanks,
    G


Comments

  • Registered Users Posts: 21,257 ✭✭✭✭Eoin


    Ok, this isn't too elegant, and I'm sure there are a load of usability issues etc, but it does seem to work ok:
    <script type="text/JavaScript">
    	function myTest()
    	{
    		var sAction = "";
    		for (var i = 0; i < myForm.myaction.length; i++)
    		{
    			if (myForm.myaction[i].checked)
    			{
    				sAction = myForm.myaction[i].value;
    			}
    		}
    		myForm.action = sAction;
    		return true;
    	}
    </script>
    
    [HTML]<form id="myForm" action="" method="post" onsubmit="return myTest()">
    <input type="text" name="txtName"><br>
    <input type="radio" id="myaction" name="myaction" value="1.asp">1<br>
    <input type="radio" id="myaction" name="myaction" value="2.asp">2<br>
    <input type="submit">
    </form>[/HTML]


  • Closed Accounts Posts: 909 ✭✭✭Gareth37


    Thanks for this, Ive just got round to using it and it works a treat :)


Advertisement