Hi there I have been at this now for 6 hours and no luck
I have a dynamically spawned <option> list however AJAX is using the <option value="this">
I want to post the contents of the option into the database, however I need to somehow post the option text instead of the option value ( as it contains a usless id only good for the AJAX working )
Is there a way I can post the option text into the DATABASE instead of the option value?
VALUE OF A OPTION
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: VALUE OF A OPTION
Not sure how to do it in javascript alone, but with jQuery you could easily do:
Moved to Javascript.
Code: Select all
var selected = $("#your_select_id option:selected");
alert(selected.text());- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: VALUE OF A OPTION
1. Change the value to use the month text which will require changing the javascript, or
2. Change the value to id so there is no value and use the id in the javascript, or
3. Create a function that is fired onsubmit() that reassigns the text to the value:
[text]select.options[select.selectedIndex].value = select.options[select.selectedIndex].text;[/text]
2. Change the value to id so there is no value and use the id in the javascript, or
3. Create a function that is fired onsubmit() that reassigns the text to the value:
[text]select.options[select.selectedIndex].value = select.options[select.selectedIndex].text;[/text]
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.