The examples in this article share with you the specific code selected by clicking the text of js to automatically locate it in the drop-down box for your reference. The specific content is as follows
<html > <head runat="server"> <title></title> <style type="text/css"> #SiteStat { width: 97px; height: 181px; } </style></head><body> <from> <script language=javascript> function foo(){ //var i = 3; var i = document.getElementById("ds").value; o = document.getElementById("SiteStat"); for (c = 0; c < o.length; c++) { dy = o.options[c].value.indexOf(i) if(dy==0) //if (o.options[c].value == i) { o.options[c].selected = true; break; } } } }</script> <select name="SiteStat" multiple="multiple" id="SiteStat"> <option value="-1" selected></option> <option value="1" >Status A</option> <option value="0">Status B</option> <option value="22">Status C</option> <option value="33">Status D</option></select></from><input type='text' name='olala' id='ds'/><input type='submit' name='sub' value='Query display' onclick="foo()"/></body></html>The above is all about this article, and I hope it will be helpful for everyone to learn JavaScript programming.