Link to home
Start Free TrialLog in
Avatar of JElster
JElsterFlag for United States of America

asked on

Jquery - how to set a select value

Hi.. again
I have the following, how can I set the 'selected' value in JQuery...  for example I need the selected value to be '1.0'
thx

 <select name="errorcodeedit" id="ErrorCodeEdit" style="width: 450px;">
                                  <%
                                  strSql = " SELECT error_code, error_description FROM eps.error_codes order by error_code "
                                  rs3.Open strSql, connection
                                  %>
                                  <option value=''>Select</option>
                                <%
                                  Do Until rs3.EOF
                                        %>
                                        <option value='<%=rs3.Fields(0).Value%>'><%=rs3.Fields(0).Value%>&nbsp;-&nbsp<%=rs3.Fields(1).Value%></option>
                                        <%
                                        rs3.movenext
                                  Loop
                                  rs3.close
                                  %>
                            </select>
ASKER CERTIFIED SOLUTION
Avatar of Rob
Rob
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JElster

ASKER

thx again
No problem. I also wanted to mention you could add the selected attribute to the relevant option tag as you were outputting it. It just depends on when you want that option selected.
If it's before the user had interacted with the page then it may be better to put in the selected attribute as you're outputting the code on the server side.
If you're going to bed to select that option because of another action the user does, well it's best left in the JavaScript