Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to create related dropdown lists for state and cities
    primarykey
    data
    text
    <p>i am trying to create a related dropdowns for cities and (related)state. here's is state.html</p> <pre><code>&lt;html&gt; &lt;head&gt;&lt;script type= "text/javascript" src = "countries2.js"&gt;&lt;/script&gt;&lt;/head&gt; &lt;body&gt; Select Country: &lt;select onchange="print_state('state',this.selectedIndex);" id="country" name ="country"&gt;&lt;/select&gt; &lt;br /&gt; City/District/State: &lt;select name ="state" id ="state"&gt;&lt;/select&gt; &lt;script language="javascript"&gt;print_country("country");&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and states.js</p> <pre><code>var country_arr = new Array("Andaman &amp; Nicobar ","Andhra pradesh","Arunachal Pradesh","maharashtra"); var s_a = new Array(); s_a[0]=""; s_a[1]="Nicobar|North and Middle Andaman|South Andaman"; s_a[2]=" Adilabad|Anantapur|Chittoor|East Godavari|Guntur|Hyderabad|Kadapa|Karimnagar|Khammam|Krishna|Kurnool|Mahabubnagar|Medak|Nalgonda|Nellore|Nizamabad|Prakasam|Rangareddy|Srikakulam|Visakhapatnam|Vizianagaram|Warangal|West Godavari"; s_a[3]="Anjaw|Changlang|Dibang Valley|East Kameng|East Siang|Kurung Kumey|Lohit|Lower Dibang Valley|Lower Subansiri|Papum Pare|Tawang|Tirap|Upper Siang|Upper Subansiri|West Kameng|West Siang"; function print_country(country_id){ // given the id of the &lt;select&gt; tag as function argument, it inserts &lt;option&gt; tags var option_str = document.getElementById(country_id); var x, i=0; for(x in country_arr){ option_str.options[i++] = new Option(country_arr[x],country_arr[x]); } } function print_state(state_id, state_index){ var option_str = document.getElementById(state_id); var x, i=0; state_index++; var state_arr = s_a[state_index].split("|"); for(x in state_arr){ option_str.options[i++] = new Option(state_arr[x],state_arr[x]); } } </code></pre> <p>when i try to select options, cities from previously selected state appear in the second dropdown box. how to avoid this??</p>
    singulars
    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