By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,835 Members | 1,391 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,835 IT Pros & Developers. It's quick & easy.

Auto Populate Text Box

P: n/a
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
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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[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>

Jul 20 '05 #2

P: n/a
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" <RE**************@cox.net> wrote in message
news:bk*********@drn.newsguy.com...
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 withthe associated fee. I would like to auto populate the fee textbox dependingon 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 tobe 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>

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.