Struts 2 – JQuery plugin: Spinner Value change event

Tags: , , , ,



<%@taglib prefix="sj" uri="/struts-jquery-tags" %>

I have used a spinner like this code below:

<sj:spinner id="SpinnerQ" onchange="" mouseWheel="true" value="%{Quantiy}" readonly="true"  max="30" min="1" >

I want to get the value when I click button up or down of spinner and show that value on message box.

Answer

Try the code below to get the value when you click button up or down of spinner and show that value on message box.

<script type="text/javascript">
 $.subscribe("changeTopic", function(event,data) {
     alert($("#spinner2").val());
 });
</script>
<sj:spinner
    label="Select a Number"
          name="spinner2"
          id="spinner2"
          onChangeTopics="changeTopic"
          min="5"
          max="50"
          step="2"
          value="25"/>


Source: stackoverflow