gerkintrigg Posted March 6, 2009 Share Posted March 6, 2009 I am trying to work out how to get the text value of a drop down box. I am using the following code but it doesn't seem to work: onchange="products_price.value=this.text;" I just need to get the "visible" part of the select box and use it as a number variable to select a price (see it in action here: http://ww.magic2k.com/alcolim/ ) Link to comment https://forums.phpfreaks.com/topic/148225-select-box-text-value/ Share on other sites More sharing options...
Adam Posted March 6, 2009 Share Posted March 6, 2009 If you set an ID for the select element you can use: onchange="document.getElementById('elements_id').value=this.text;" If the form has a name: onchange="documents.forms['form_name'].value=this.text;" Or if you work out the form number: onchange="document.forms[0].products_price.value=this.text;" Remember though the form number starts from 0 and not 1! Adam Link to comment https://forums.phpfreaks.com/topic/148225-select-box-text-value/#findComment-778148 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.