jquery-archive / jquery-mobile

jQuery Mobile Framework
https://jquerymobile.com
Other
9.69k stars 2.4k forks source link

Set select value is not changing the visible value #1189

Closed ddluk closed 13 years ago

ddluk commented 13 years ago

The problem is with following code:

[code]

    <select name="sh1a" id="sh1"> 
      <option value="0"></option> 
      <option value="1">UPS</option> 
      <option value="2">USPS</option> 
      <option value="3">FEDEX</option> 
      <option value="4">DHL USA</option> 
      <option value="5">DHL DE</option> 
      <option value="6">DHL PL</option> 
      <option value="7">ONTRAC</option> 
    </select> 
 </div>[/code](Sorry for adding code but without it github display the select list)

When I'm trying to update value using:

document.getElementById("sh1").value = "1";

OR

$("#sh1").val("1");

value is changing but on the select element visible is still the old value.

toddparker commented 13 years ago

Can you set up a test page on JS bin? Like this: http://jsbin.com/alayo3/

toddparker commented 13 years ago

f you manipulate a select via JavaScript, you must call the refresh method on it to update the visual styling. Here is an example:

var myselect = $("select#foo"); myselect[0].selectedIndex = 3; myselect.selectmenu("refresh");