I need to send the value and the text of a select box input in the php file I’m writing. I have jquery included.
I am passing the value in order to query the database, but since the name associated with the records is in another table, and I don’t want to do a join, I figure it would be easier to send the name (which has already been retrieved). I figure the easiest thing to do is to populate the value of a hidden input with something like this:
$('#individ option:selected').text()
Example
echo "<select id='individ' name='individ'>";
echo "<option value='1'>John Smith</option>";
echo "<option value='2'>Jim Dandy</option>";
echo "<option value='3'>Jane Fletcher</option>";
echo "</select><br />";
echo "<input type='hidden' name='selected_name' value=''>"; //the value of this needs to be the text from the select above
I don’t know if that’s what you’re trying to do. I don’t see why you couldn’t just get the value of the select on post.
If you need to do it without submitting, you’re going to have to do some ajax.