Dynamic box getting the labels from a Combo box

  • steveg89
  • Born
  • Born
  • steveg89
  • Posts: 1
  • Loc: New York

Post 3+ Months Ago

How can I send a combo box'es labels to a text box? I would just like it to display whatever the user picked in a text box. I tried:

objComboListener = new Object();
objComboListener.change = function(eventObj){
mon.text = eventObj.target.value;
}
mon_cb.addEventListener("change", objComboListener);


mon.text is the box, mon_cb is the combo box.

There are two problems with the above code though:
A. It displays my data, and not the labels.
B. It only displays the first selection. Eg; if I choose something, it will display that thing, but if I choose another choice, it keeps displaying the first selection.

Does anyone know what I messed up?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

The code is working fine. But you're right, it displayes the data, not the labels, but you can always have the same data and labels. I think the data it's for indexing though, so it will be faster. Like you have an array of strings,
and you place in the data only the indexes and in the labels the values.
Therefor when you want to display the labels, you just go with: mon.text = valuesArray[eventObj.target.value];
As for point B, i'd rather think you have the same data value for all the items, because i tested it and it works just fine.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 8 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.