Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get an form selected value jQuery

How should I get an form input selected value using jQuery

<form:select path="amtAppMonitResltVO.monitStat" id="amtAppMonitResltVO.monitStat" cssClass="state">
  <option value="">선택</option>
  <form:options name="monit" items="${apps}" itemValue="subCd" itemLabel="subCdNm" />
</form:select> 
<img src="<c:url value='/resources/img/read.png'/>" class="read" id="appStatSearch"></td>
like image 892
min moica Avatar asked Jan 01 '26 18:01

min moica


1 Answers

You just need get the .val() of the amtAppCollInfoVO_mkType select input:

var some_var = $('#amtAppCollInfoVO_mkType').val();

For pure Javascript just switch .val() to .value

Note that your current option does not have a value.

Note that since you have the . in your id you have to add double \ to your Javascript code:

<script>
    $(function() {
        $('#amtAppMonitResltVO\\.monitStat').on('click', function() {
            var moniStat = $('#amtAppMonitResltVO\\.monitStat').val();

            console.log(moniStat);
        })
    })
</script>

Credit goes here for this answer.

like image 68
Sam Avatar answered Jan 03 '26 08:01

Sam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!