Home > Back-end >  Post form, trim value from combo
Post form, trim value from combo

Time:01-24

I have a problem. I want to create a form, and i want to post selected value, but i also want to add extra info to each combobox option which i dont want to send.

combobox

I have that options in combo. And i want to send only value before BuildDate. I can trim that value after send - using $rev = $_GET['version']); $temp = explode(" ", $rev); $rev = $temp[0]; but i would like to not see this in url

CodePudding user response:

If you put the ID as the value attribute in each option, that value only will be submitted to the the server, instead of the visible text.

E.g.

<select name="yourdropdown">
  <option value="A">A - 100</option>
  <option value="B">B - 200</option>
</select>

In that example, if the first option is selected then only A is submitted to the server, because that's the value of the option.

Documentation: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/option

Also, if you don't want form data to be visible in the URL, you can submit the data via POST (rather than the default GET) - that way the data is transmitted in the body of the request instead.

  •  Tags:  
  • Related