This tutorial applies for Classic ASP, JSP, and PHP but not for ASP.NET. ASP.NET developers should see the ASP.NET tutorials instead.
We could be referring to four different things when we say "How do I get the Combo value?"
What is currently in the text box?
(or)
What is the selected value from the list?
(or)
What value was submitted in the form?
(or)
What are the values of the top record?
What is currently in the text box?
Here is an alert pop up that will show the current text box value. Assuming your Combo ID is "myCombo":
What is the selected value from the list?
When the user selects something from the list, a JavaScript Array is populated with all the values from that row of the XML. Assuming your Combo ID is "myCombo":
This will output the whole concatenated array:
This will output the 1st and 2nd columns of that array
What Value was Submitted with the Form?
When the user submits the combo with a form, several form fields are created which can be read by the server. Assuming your Combo ID was "myCombo", and there were two columns of data in the list XML, the available form fields will include:
"myCombo" - The actual text in the textbox.
"myComboSelectedValue0" - The first data column of the selected row.
"myComboSelectedValue1" - The second data column of the selected row.
What are the Values of the Top Record?
You may want to grab the values of the top record either when a record is selected, or as the user types. This is possible with the use of the GetFieldFromActiveRow( ColumnName ) method.
For example, let"s set up our combo to do something when a record is chosen:
In this unbound combo we have wired our onSelectEvent to a function called PopulateForm(). We have also created a form with two fields.
Next we write PopulateForm() function:
Now, when the user selects a record, the values of the two columns are passed into the form.