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/ ) Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.