2

I want to reset my form elements on change of select box value. The below is the example.

<sj:select
        id="uniqueId"
    requiredLabel="true" 

        name="choosenvalue"
        list="displayItems"
        listKey="key"
        listValue="value"
        headerKey="-1"
        headerValue="Choose displayed Items"

        onChangeTopics="change"
        href="%{findSelectedValues}"

    />  
<sj:spinner
    name="spinnner"
    id="spinner"
    min="1"
    step="1"
    value="1" />

<sj:datepicker  name="datepicker" requiredLabel="true" minDate="0" timepicker="true"  />

How to reset the values of datepicker and spinner from the values retrieved form the database on change the select box?

Roman C
  • 49,761
  • 33
  • 66
  • 176
Lokesha S
  • 75
  • 1
  • 4
  • 16

1 Answers1

0

It's easily done via subscribing to the changeTopic

<script type="text/javascript">
 $.subscribe("changeTopic", function(event,data) {
     $("#formID").resetForm();
 });
</script>

where the formID is an id of the form element. So, in select tag

onChangeTopics="changeTopic"
Roman C
  • 49,761
  • 33
  • 66
  • 176
  • Thanks for the reply. Probably I didn't put it correctly. I want to set the values of spinner and date field on change of select box the response comes back as JSON. – Lokesha S Jan 12 '14 at 07:04
  • Thanks Roman. It works with Jquery ajax. But just thinking if something is built into plugin so that we don't have to use Jquery directly – Lokesha S Jan 12 '14 at 09:46
  • The plugin uses jQuery API to make Ajax requests from the tags managed by the plugin like anchor or div. It seems ugly to create such elements for triggering events on them only instead of use jQuery API directly. – Roman C Jan 12 '14 at 10:11