C. David Rossen said:
Hello:
I have a registration form for classes. Each class has a fee. I have a
drop down box whereby the user chooses his class. There is a textbox with
the associated fee. I would like to auto populate the fee textbox depending
on what class the user chooses. In the email, the value of the drop down
box has to be the name of the class and the value of the fee text box has to
be the fee. Can someone please help me in accomplishing this? Thank you.
You may not really want to do that.
It would be trivial to hack your page to make it send your
form with whatever class one wants, and whatever price they
choose to pay for it. And I really hope you're not asking
people to send personal/financial information through email.
However:
<html>
<head>
<script type="text/javascript">
function populate(item){
for(var i=0;i<item.form.elements.length;i++){
if(item==item.form.elements[i]){
item.form.elements[i+1].value=
item.options[item.selectedIndex].value;
}
}
}
</script>
</head>
<body>
<form>
<select onchange="populate(this)">
<option value="">--none--</option>
<option value="2.50">alpha</option>
<option value="1.95">beta</option>
<option value="3.00">gamma</option>
</select>
<input type="text"><br>
<select onchange="populate(this)">
<option value="">--none--</option>
<option value="2.50">alpha</option>
<option value="1.95">beta</option>
<option value="3.00">gamma</option>
</select>
<input type="text"><br>
<select onchange="populate(this)">
<option value="">--none--</option>
<option value="2.50">alpha</option>
<option value="1.95">beta</option>
<option value="3.00">gamma</option>
</select>
<input type="text"><br>
</form>
</body>
</html>