Click to See Complete Forum and Search --> : Combo box values


forrest06
07-28-2003, 04:22 PM
I have some functions that populate a combo box depending upon what was selected in the proceeding combo box. This is done for four combo boxes.

Does anyone know how I can output in HTML, the value that is shown in the last combo box as I cannot find the variable that the value is stored in?

pyro
07-28-2003, 07:22 PM
I don't understand what you mean. Could you explain what you need a bit better, and perhaps show some code?

forrest06
07-29-2003, 05:50 AM
I am trying to create a mileage calculator. The code posted is a little long winded. At the beginning of the code is just the data added to the arrays which will be shown in the combo boxes. I have removed a large amount of these variables to reduce the file size.

Firstly, a value from the first combo box is selected. This is a country. This then populates the second combo box with all of the counties in that country. Thirdly, when a county is selected, all of the towns/cities in that county are displayed in the third combo box. When a towns/city is selected, the mileage is displayed in the fourth combo box.

I want to be able to store that mileage value in a variable so I can use it to perform calculations on and then display on the screen after the selections have been made. Any ideas?

xataku_nakusute
07-29-2003, 06:02 AM
give the select tags names and then:

var mileage = document.nameofselecttag.value;

this becomes the variable of your mileage

pyro
07-29-2003, 07:23 AM
Actually, you are going to need something more like this to get the value of a select box:

document.formname.selectetname.options[document.formname.selectname.selectedIndex].value;