Jump to content

Recommended Posts

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.