Jump to content

get text form listbox


itazev

Recommended Posts

hmm, lets try to figure this out.

 

if a select looks like this:

 

<select id="test_select"><option>one</option><option>two</option></select>

 

var sel = document.getElementById('test_select');
var sel_children = sel.childNodes;
var opt = '';
for(var i = 0; i < sel_children.length; i++){
if(sel_children[i].hasChildNodes()){
opt += sel_children[i].firstChild.nodeValue +"\n";
}
}

 

alert(opt);

 

that should work, havent tested it. adapted from http://developer.mozilla.org/en/docs/DOM:element.childNodes

Link to comment
https://forums.phpfreaks.com/topic/66348-get-text-form-listbox/#findComment-332075
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.