how to get html select box option selecteditem real value

38 views Asked by At

I'm getting DB data from the select box list. When saving, the option value is 1, but is there a way to pass the id of the selected item as well? When saving, yes or no is 0 or 1, but the id of the actually selected itemList should be stored in another table.

$("#racker_enabled").change(function(){
   var selected_id = $("#tracker_enabled option:selected").val();      // option value 1만 찍힘..

});
<select name="tracker_enabled" id="tracker_enabled">

<option th:value="0"  th:text="#{projects.Notused}"> </option>

<option  th:value="1"  th:if="${project.tracker_enabled == T(com.Type.EnumYn).Y}" 

             th:each="issuetrackerList:${issuetrackerList}"

            th:utext="${issuetrackerList.name}"

            th:selected="${issuetrackerList.id == selectedIssuetracker.issue_tracker_id}">

</option>

</select>

// Data contained in the model // I need the id value in bold below. trackerList :

[IssueTracker (id=13, tracker_id=null, name=mantis, tracker_name=null, type=null, configuraion=null),

IssueTracker(id=14, tracker_id=null, name=mantis113,tracker_name=null, type=null, configuraion=null),

IssueTracker(id=11, tracker_id=null, name=Test IssueTracker, tracker_name=null, type=null, configuraion=null),

IssueTracker(id=15, tracker_id=null, name=gggg, tracker_name=null, type=null, configuraion=null)]

selectedTracker :

IssueTracker(id=200, issue_tracker_id=11, name=1111, issue_tracker_name=Test Tracker, type=1, configuraion=null)

0

There are 0 answers