How to pass id value in the selection list in the form using message or receive?

Select the list in the form, I know that there is no problem passing the parameter value via message or receiving. But if I also want to pass the id value, is it possible and how? For instance:

<form action="Test.php" method="POST"> <select name="select" id = '1'> <option value="">Select a Status</option> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> <input type="submit" value="submit"/> </form> 

And here is a simple PHP print code:

 <?php print_r($_POST['select']); ?> 

It can print the value of the selected parameter, but how to change the code if I also want to publish the id value, which is 1. I want to do this because I want the identifier to become a variable to store some numbers. Thanks!

+4
source share
2 answers

The id attribute is intended solely for use in client code. If you want to transfer additional data, use hidden inputs - this is what they are for.

 <input type="hidden" name="select_extra" value="1"> <select name="select"> <option value="">Select a Status</option> <option value="0">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> </select> 
+5
source

The identifier will not be transmitted automatically in HTTP.

You need:

  • Use input hidden
  • Use a special name. I.E. <select name="select_1" id="1">...</select
+1
source

All Articles