Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Javascript Radio Button to Select Relevant Login Page

  • 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, Registered Users 2 Posts: 21,278 ✭✭✭✭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