Auto Populate Text Box

C

C. David Rossen

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.

David
 
L

Lee

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){
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>
 
C

C. David Rossen

Lee:
Here is the problem. I need the value of the class (alpha, beta or gamma)
to be just that in the email, not the fee amount. So, my question is is
there a way to populate the fee text box with the number while maintaining
the value of the name of the class? Thanks.

David

Lee said:
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){
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>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top