Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This code should work :</p> <p> Simulate clicks on options </p> <pre><code>&lt;style type="text/css"&gt; div { width:30px; height:30px; margin:4px; cursor:pointer; } #click-object-1{background-color:#F00;} #click-object-2{background-color:#0F0;} #click-object-3{background-color:#00F;} #click-object-4{background-color:#FF0;} &lt;/style&gt; &lt;script type="text/javascript"&gt; function grabClick(selid , optionid){ var arr = new Array(); arr['empty'] = "0"; arr['fireaway'] = 1; arr['groundearth'] = 2; arr['watermelon'] = 1; arr['catchwind'] = 2; changeTo(selid, arr[optionid]); setTimeout(function(){changeTo(selid, "0")}, 1000); setTimeout(function(){changeTo(selid, arr[optionid])}, 2000); } function changeTo(sd, od){ var sel = document.getElementById(sd); sel.options[od].selected = true; } &lt;/script&gt; &lt;body&gt; &lt;form action=""&gt; &lt;fieldset&gt; &lt;ul style="list-style:none;"&gt; &lt;li&gt; &lt;select id="select_items_first" name="SelectItemsFirst"&gt; &lt;option id="empty" value="choose"&gt;Please choose&lt;/option&gt; &lt;option id="fireaway" value="xjakgd"&gt;Fire&lt;/option&gt; &lt;option id="groundearth" value="yuygas"&gt;Earth&lt;/option&gt; &lt;/select&gt; &lt;/li&gt; &lt;li&gt; &lt;select id="select_items_second" name="SelectItemsSecond"&gt; &lt;option id="empty" value="choosemore"&gt;Please choose&lt;/option&gt; &lt;option id="watermelon" value="piowqe"&gt;Water&lt;/option&gt; &lt;option id="catchwind" value="mnbvzi"&gt;Wind&lt;/option&gt; &lt;/select&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;div id="click-object-1" onclick='grabClick("select_items_first","fireaway");'&gt;&lt;/div&gt; &lt;div id="click-object-2" onclick='grabClick("select_items_first","groundearth");'&gt;&lt;/div&gt; &lt;br /&gt; &lt;div id="click-object-3" onclick='grabClick("select_items_second","watermelon");'&gt;&lt;/div&gt; &lt;div id="click-object-4" onclick='grabClick("select_items_second","catchwind");'&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

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