PHP: HTML: send HTML select option attribute in POST

前端 未结 5 411
走了就别回头了
走了就别回头了 2020-12-30 00:37

I want to send the selected item value along with the some attribute (stud_name) value. Is there any functionality in PHP to do so? Here is the example one.

         


        
5条回答
  •  一生所求
    2020-12-30 01:33

    You will have to use JavaScript. The browser will only send the value of the selected option (so its not PHP's fault).

    What your JS should do is hook into the form's submit event and create a hidden field with the value of the selected option's stud_name value. This hidden field will then get sent to the server.

    That being said ... you shouldn't relay on the client to provide the correct data. You already know what stud_name should be for a given value on the server (since you are outputting it). So just apply the same logic when you are processing the form.

提交回复
热议问题