<select id=\"IntentNature\" name=\"IntentNature\">";
"                    <option value=\"1\">全职<\/option>";
"                    <option value=\"2\">兼职<\/option>";
"                    <option value=\"3\">实习<\/option>";
</select>
查询出来的数据 变量str  怎么让它在下拉列表狂默认显示

解决方案 »

  1.   

    document.getElementById("IntentNature").value = str;
      

  2.   

    例如默认显示为兼职
    <html>
    <head>
    <script>
    onload = function(){
    var str = "<select id=\"IntentNature\" name=\"IntentNature\">"
    +"<option value=\"1\">全职<\/option>"
    +"<option value=\"2\">兼职<\/option>"
    +"<option value=\"3\">实习<\/option>"
    +"</select>";
      document.getElementById("div").innerHTML = str;
      document.getElementById("IntentNature").value = 2;
    }</script>
    </head>
    <body>
    <div id="div"></div>
    </body>
    </html>