Can someone help me with a basic javascript event function?
Alright, so basically, I've just started practicing combining forms with javascript.
I have a simple dropbox which asks the user to select either ID or Name as means of selecting a student.
If they say 'ID' I want them to open 'Form2' which asks them to enter the user's ID.
However, if they select 'Name' I want them to open 'Form3' which asks them to enter the user's Name.
My function worked until I put in if statements. So that is what I need help with, aligning my if statements correctly so that if ID is selected from 'form1,' then 'form2' is brought up. Otherwise, 'form3' is brought up.
My code so far is below.
<script language="javascript">
function showForm()
{
if ($_REQUEST['selectioncriteria']=="ID")
{
document.getElementById('formHolder').style.displa y="";
}
else
{
document.getElementById('formHolder2').style.displ ay="";
}
}
</script>
</head>
<body>
<form name=form1 action="" method=post>
<select name=selectioncriteria size=1 onchange=javascript:showForm()>
<option>--Find student by ID or Name--
<option>ID
<option>Name
</select>
<div id=formHolder style=display:none;>
<form name=form2 action="" method=post>
<p> Enter the ID of the person who's profile is to be updated: <input type=text name=choice_id/></p>
</form>
</div>
<div id=formHolder2 style=display:none;>
<form name=form3 action="" method=post>
<p> Enter the name of the person who's profile is to be updated: <input type=text name=choice_name/></p>
</form>
</div>
|