![]() |
Help getting value from a drop down field
I have a form where I am collecting information from prospective clients. One of the fields is "County" wherein I have listed all the counties that I provide services, and the cost for that county. When they choose their county from the drop down list, I would like a hidden field called "County_Cost" to automatically be populated with the correct amount. Even if they go back and choose a different county, that field should update. That way, when they're done entering all their information, and they click submit, a contract is sent to them with the correct total.
In my drop down list, I currently have each county listed like "Wake,46" and then another county is "Franklin,75" and so on. The number after the comma is obviously, the cost for that county. Any help would be greatly appreciated. I'm not that good at Java and just don't have time this week to do the research. |
Are you asking this for Java or JavaScript?
|
Something like this?
Code:
<script src="http://code.jquery.com/jquery-latest.js"></script>-Riku |
Assuming that you mean Javascript (a totally different language to Java in spite of the confusingly similar names):-
Code:
<select id = "counties" onchange = "showvalue()">Riku's code uses jQuery. You did not specify that, and in any case it is silly to download the large overhead of a Javascript framework to accomplish something so simple. The value of a select list is simply obtained with var val = document.getElementById("counties").value; No need for any reference to selectedIndex. Quizmaster: Which surname was shared by a historical outlaw called "Butch" and a fictional cowboy called "Hopalong"? Contestant: Lesbian. |
Got this idea from http://www.codeproject.com/Articles/...-list-selectio
Code:
<!DOCTYPE html> |
| All times are GMT +1. The time now is 08:04 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.