Get Text From Option Tag in PHP -
i want text inside option tags value.
ex:
<select name="make"> <option value="5"> text </option> </select>
i used $_post['make']; , value (5) want get both value , text .
how can using php.
what this? think it's best solution because have separated fields each data. 1 hidden field updated @ each change , avoids hardcoding mappings.
this inside html:
<select name='make' onchange="settextfield(this)"> <option value = '' selected> none </option> <option value = '5'> text 5 </option> <option value = '7'> text 7 </option> <option value = '9'> text 9 </option> </select> <input id="make_text" type = "hidden" name = "make_text" value = "" /> <script type="text/javascript"> function settextfield(ddl) { document.getelementbyid('make_text').value = ddl.options[ddl.selectedindex].text; } </script>
this inside php:
<?php $value = $_post["make"]; $text = $_post["make_text"]; ?>
Comments
Post a Comment