redinferno
12-12-2008, 03:36 PM
I have a drop down menu. When the user selects a certain item from the drop down menu i want to make the form's "action" property and the "name" property of certain input fields change.
Example: If they select "billing" I want the forms action to change to "billing.php" so that when they click the login button they will be taken to "billing.php".
Here is the XHTML code I am using so far.
<form action="#" id="LoginForm">
<div>
<input type="submit" id="submit" value="">
<input type="text" class="textbox" id="username" name="username" value="username">
<input type="password" class="textbox" id="password" name="password" value="******">
<select id="PanelSelection">
<option onfocus="ChangeFormBilling()"> Billing Panel </option>
<option onchange="ChangeFormGame()"> Game Panel </option>
<option onchange="ChangeFormVoice()"> Voice Panel </option>
</select>
</div>
</form>
and this is the javascript i am using.
function ChangeFormBilling()
{
document.getElementById("LoginForm").action = "billing.php";
document.getElementById("username").name = "billinguser";
document.getElementById("password").name = "billingpass";
}
function ChangeFormGame()
{
document.getElementById("LoginForm").action = "game.php";
document.getElementById("username").name = "gameuser";
document.getElementById("password").name = "gamepass";
}
function ChangeFormVoice()
{
document.getElementById("LoginForm").action = "voice.php";
document.getElementById("username").name = "voiceuser";
document.getElementById("password").name = "voicepass";
}
Example: If they select "billing" I want the forms action to change to "billing.php" so that when they click the login button they will be taken to "billing.php".
Here is the XHTML code I am using so far.
<form action="#" id="LoginForm">
<div>
<input type="submit" id="submit" value="">
<input type="text" class="textbox" id="username" name="username" value="username">
<input type="password" class="textbox" id="password" name="password" value="******">
<select id="PanelSelection">
<option onfocus="ChangeFormBilling()"> Billing Panel </option>
<option onchange="ChangeFormGame()"> Game Panel </option>
<option onchange="ChangeFormVoice()"> Voice Panel </option>
</select>
</div>
</form>
and this is the javascript i am using.
function ChangeFormBilling()
{
document.getElementById("LoginForm").action = "billing.php";
document.getElementById("username").name = "billinguser";
document.getElementById("password").name = "billingpass";
}
function ChangeFormGame()
{
document.getElementById("LoginForm").action = "game.php";
document.getElementById("username").name = "gameuser";
document.getElementById("password").name = "gamepass";
}
function ChangeFormVoice()
{
document.getElementById("LoginForm").action = "voice.php";
document.getElementById("username").name = "voiceuser";
document.getElementById("password").name = "voicepass";
}