简体   繁体   中英

How to send values with <select> <option> form using this.form.submit()

This is my code:

<form action="" method="GET">
    <input type="hidden" value=" <?php echo $category1; ?> ">
    <input type="hidden" value=" <?php echo $category2; ?> ">
    <select onchange="this.form.submit()" name="sortby">
       <option value="popularity">Popularity</option>
       <option value="release_dateo" >Release Date: Oldest</option>
       <option value="vote_count" >Number Of Votes</option>
   </select>
</form>

I am using this form because, i want to submit the form without submit button.

What this code do:

It submits the <option> value, if someone click on an option.

What I want it to do:

If someone click on <option> , if sends option value + the hidden values.

The url is something like this before submitting the form:

index.php?category1=abc&category2=xyz&sortby=selectedoptionvaluehere

You are missing name attribute at hidden input's to be sent..

<input type="hidden" name="category1" value=" <?php echo $category1; ?> ">
<input type="hidden" name="category2" value=" <?php echo $category2; ?> ">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM