Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ComboBox Selection using getElementById

Status
Not open for further replies.

DustpanDave

Programmer
Jun 23, 2005
3
DE
Hi All.

I have a ComboBox that has, say, 5 items in it. These display as text in the Combo box but are stored as integers in the DB.

How do i get the Text value rather than the ID value of this selected item in the combo box?

I am trying to display and hide a certain text box when a certain item in the combo box is selected.

i beleive it has something to do with options.value part?

MY CODE SO FAR:
function HideTitleONChange(evt)
{
var ctlState = document.getElementById("ProfCrdTitleID");
var ctlOtherTitle = document.getElementById("Title");

if ( ctlState.options.value == "2"){
ctlOtherTitle.style.visibility = "visible";
ctlOtherTitle.style.value =="";}
else{
ctlOtherTitle.style.visibility = "hidden";
ctlOtherTitle.style.value =="";}
return true;
}
var ctlState = document.getElementById("ProfCrdTitleID");
addEvent(ctlState, "change", HideTitleONChange);

Thanks Dave
 
>ctlState.options.value
That makes not much sense. Instead, it is this.
[tt]ctlState.options[red][ctlState.selectedIndex][/red].value //for value
ctlState.options[red][ctlState.selectedIndex][/red].text //for text you asked for
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top