PHP code to get selected text of a combo box

前端 未结 7 1032
死守一世寂寞
死守一世寂寞 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:31

    Put whatever you want to send to PHP in the value attribute.

      
    

    You can also omit the value attribute. It defaults to using the text.

    If you don't want to change the HTML, you can put an array in your PHP to translate the values:

    $makes = array(2 => 'Toyota',
                   3 => 'Nissan');
    
    $maker = $makes[$_POST['Make']];
    

提交回复
热议问题