Note that there are some explanatory texts on larger screens.

plurals
  1. POjavascript selected value
    primarykey
    data
    text
    <p>I have created function for creating a div, when u selet the value in dropdown box , based upon the length the number of divs will be created , so the code is</p> <pre><code>&lt;select onchange="test()" id="selected_opt"&gt; &lt;option value="0" selected&gt;-Select-&lt;/option&gt; &lt;option value="1"&gt;Communication&lt;/option&gt; &lt;option value="2"&gt;XXXXXXXXXXXXX&lt;/option&gt; &lt;/select&gt; </code></pre> <p>the function test is </p> <pre><code>function test(){ var result = get_id.options[get_id.selectedIndex].value; if(result == 1){ var i = 0, c = model_details_json.communication, j = c.length, communications_div = document.getElementById("model_communication"); if(j == 0){ alert('nothing'); } for (; i&lt;j; i++){ var communication = c[i]; var create_div = document.createElement('div'); create_div.id = 'communication_id'+i; create_div.name = 'communication'; var create_anchor = document.createElement('a'); create_anchor.innerHTML = communication.communication_name; communications_div.appendChild(create_div); document.getElementById(create_div.id).appendChild(create_anchor); create_anchor.setAttribute("href", "javascript:void(0);"); create_anchor.setAttribute("onclick","sample('"+communication.communication_name+"','"+create_div.name+"')"); } } </code></pre> <p>for example the length is 6 means the six number of divs will be created , so what the problem is when i again click on communication in select dropdown i.e already the six divs have been created , when do it again then agin six divs are created , so totally 12 divs created when u do it again it goes for 6 multiples....... </p> <p>so what i need is the number of div would not be repeated. and it should be validate whether the user is clicking the same value in dropdown </p>
    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.
 

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