Note that there are some explanatory texts on larger screens.

plurals
  1. POHide options in a select list using jQuery
    primarykey
    data
    text
    <p>How can I hide room numbers that is not at Hotel1 and send chosen room number to next page when you click on submit button. As it is now I will be forced to send only the id for chosen hotel because i need to have the value for selHotel options and selroom the same. </p> <p>I'm using php, html and Sqlite database. hotelrows and roomrows contains all rows of hotel table and rooms table. Can anyone give me an idea of ​​how I could get this to work? Ie when choosing Hotel1 I can just choose room 101 or 102 in selroom for example. (Sorry if my English is bad, hopefully someone understands what I'm asking for.)</p> <pre><code>Hotels: id.....Hotel 1......Hotel1 2......Hotel2 Rooms: hid....Room# 1.......101 1.......102 2.......301 </code></pre> <p>My php/html:</p> <pre><code>&lt;select id="selHotel" name="selH"&gt; &lt;option value="default" selected&gt; Select hotel&lt;/option&gt; &lt;?php foreach($hotelrows as $row) { echo "&lt;option value='". $row['id'] . "'&gt;". $row['hotelname'] . "&lt;/option&gt;"; } ?&gt; &lt;/select&gt; &lt;select id="selroom" name="selr"&gt; &lt;option value="default" selected&gt;Select room &lt;/option&gt; &lt;?php foreach($roomrows as $row) { echo "&lt;option value='". $row['hid'] . "'&gt;". $row['roomnum'] . "&lt;/option&gt;"; } ?&gt; &lt;/select&gt; </code></pre> <p>jQuery to hide Hotel2 Rooms then i choose Hotel1:</p> <pre><code>$("#selHotel").change(function(){ var hotelVal = $(this).find("option:selected").val(); $('#selroom option').hide(); $('#selroom option[value='+hotelVal+']').show(); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload