PHP code to get selected text of a combo box

前端 未结 7 937
死守一世寂寞
死守一世寂寞 2020-12-10 08:42

I have a combo box named \"Make\". In that combo box I\'m loading vehicle manufacturer names. When I click SEARCH button I want to display the selected manufacturer name. Be

相关标签:
7条回答
  • 2020-12-10 09:36

    you can make a jQuery onChange event to get the text from the combobox when the user select one of them:

    <script>    
         $( "select" )
         .change(function () {
         var str = "";
         $( "select option:selected" ).each(function() {
         str += $( this ).text() + " ";
         });
         $('#EvaluationName').val(str);
         })
         .change();
     </script>
    

    When you select an option, it will save the text in an Input hidde

      <input type="hidden" id="EvaluationName" name="EvaluationName" value="<?= $Evaluation ?>" />
    

    After that, when you submit the form, just catch up the value of the input

    $Evaluation = $_REQUEST['EvaluationName'];
    

    Then you can do wathever you want with the text, for instance save it in a session variable and send it to other page. etc.

    0 讨论(0)
提交回复
热议问题