Populate select form field via jquery

Populate select form field via jquery

I have a form where a user may select a box from above which will query the database and autofill in the fields.  This works properly for all of my input text fields but I have a select box where a user selects their state that I am unable to get to properly populate.


The select box is populated on page load in the following format....
  1. <select id="state" name="state">
  2. <option value="1">ALABAMA</option>
  3. <option value="2">ALASKA</option>
  4. </select>
etc...
The jquery code I utilize to populate my form fields is as follows...
  1. <script type="text/javascript">
  2. function getUserInfo(custid) {
  3. $.getJSON("cfc/UserTransactions.cfc",
  4. {
  5. method: "getUserData",
  6. customerid: custid,
  7. },
  8. function(data) {
  9. var columnMa
  10. for (var i = 0; i < data.COLUMNS.length; i++) {
  11. columnMap[data.COLUMNS[i]] = i
  12. }
  13. for (var i = 0; i < data.DATA.length; i++) {
  14. $("#first_name").val(data.DATA[i][columnMap.FIRST_NAME]);
  15. $("#last_name").val(data.DATA[i][columnMap.LAST_NAME]);
  16. $("#emailpayee").val(data.DATA[i][columnMap.EMAIL]);
  17. $("#phone").val(data.DATA[i][columnMap.PHONE]);
  18. $("#address1").val(data.DATA[i][columnMap.ADDRESS]);
  19.                               $("#address2").val(data.DATA[i][columnMap.ADDRESS2]);
  20. $("#city").val(data.DATA[i][columnMap.CITY]);
  21. $("#state").val(data.DATA[i][columnMap.STATEID]);
  22. $("#zipcode").val(data.DATA[i][columnMap.ZIP]);
  23. }
  24. }
  25. )};
  26. </script>
Everything populates correctly except where I try to set the val on the state select field.  It does not change at all.  I need it to display the statename with the value of the state (number).  Thank you in advance for any help you can provide!