Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Post form, trim value from combo

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading