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>
LVL 1
JElsterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RobOwner (Aidellio)Commented:
http://jsbin.com/vicay/1/edit

$(function() {
	$('#ErrorCodeEdit').val('1.0');
});

Open in new window


<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
<select id='ErrorCodeEdit'>
	<option value="0">--select--</option>
	<option value="1.0">one point zero</option>
	<option value="2.0">two</option>
	<option value="3.0">three</option>
	</select>
</body>
</html>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JElsterAuthor Commented:
thx again
0
RobOwner (Aidellio)Commented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.