Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd a div on change of select box value not working fine
    primarykey
    data
    text
    <p>below code works fine but want to some improvement like i want to append and remove the select person div on every change of select box value</p> <p>check this website <a href="https://i.stack.imgur.com/HbsZi.png" rel="nofollow noreferrer">http://www.travelnow.com/</a> <a href="https://i.stack.imgur.com/HbsZi.png" rel="nofollow noreferrer">1</a>: <a href="http://www.travelnow.com/" rel="nofollow noreferrer">http://www.travelnow.com/</a> rooms select option feature <img src="https://i.stack.imgur.com/HbsZi.png" alt="enter image description here"></p> <p>My HTML CODE</p> <pre><code>&lt;select id="roomOptions"&gt; &lt;option value="1" selected="selected"&gt; 1 &lt;/option&gt; &lt;option value="2"&gt; 2 &lt;/option&gt; &lt;option value="3"&gt; 3 &lt;/option&gt; &lt;/select&gt; &lt;br/&gt; &lt;div id="text"&gt; &lt;label&gt; Adults (18+) &lt;/label&gt; &lt;label&gt; Children (0-17) &lt;/label&gt; &lt;/div&gt; &lt;div class="select-person"&gt; &lt;label&gt; Adults (18+) &lt;/label&gt; &lt;select&gt; &lt;option value="1"&gt; 1 &lt;/option&gt; &lt;option value="2" selected="selected"&gt; 2 &lt;/option&gt; &lt;/select&gt; &lt;label&gt; Children (0-17) &lt;/label&gt; &lt;select&gt; &lt;option value="0" selected="selected"&gt; 0 &lt;/option&gt; &lt;option value="1"&gt; 1 &lt;/option&gt; &lt;option value="2"&gt; 2 &lt;/option&gt; &lt;/select&gt; &lt;/div&gt; </code></pre> <p>MY SCRIPT</p> <pre><code>$('select#roomOptions').change(function () { $('div#text select').remove(); var val = $(this).val(); for (var x = 1; x &lt; val; x++) { var createSelectBox = '&lt;select id="adults"&gt;&lt;option value="1"&gt;1&lt;/option&gt;&lt;/select&gt;&lt;option value="2"&gt;2&lt;/option&gt;&lt;/select&gt;&lt;option value="3"&gt;3&lt;/option&gt;&lt;/select&gt;&lt;select id="children"&gt;&lt;option value="1"&gt;1&lt;/option&gt;&lt;/select&gt;&lt;option value="2"&gt;2&lt;/option&gt;&lt;/select&gt;&lt;option value="3"&gt;3&lt;/option&gt;&lt;/select&gt;'; $('div#text').append(createSelectBox); } }); </code></pre>
    singulars
    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.
    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