0 Replies Latest reply on Aug 4, 2011 2:07 PM by cobar

    JQuery radio button help

    cobar

      I need help with jQuery. I am basically trying to capture a checked value and show or hide another (checkbox) component. However, I am not able to obtain the checked input value correctly.

       

      <rich:jQuery id="xprtWhtQryOn" selector="#xprtSumAnlRdo"    query="click(function(){alert(jQuery(':checked').val());})"/>

      This returns the same default value 'S' regardless which input is checked.

       

      <rich:jQuery id="xprtWhtQryOn" selector="#xprtSumAnlRdo"    query="change(function(){alert(jQuery(':checked').val());})"/>

      This does not fire in IE 8.

       

       

      <rich:jQuery id="xprtWhtQryOn" selector="#xprtSumAnlRdo"query="click(function(){alert(jQuery(':nth(1)').val());})"/>

      and

      <rich:jQuery id="xprtWhtQryOn" selector="#xprtSumAnlRdo"query="click(function(){alert(jQuery(':last-child').val());})"/>

      return empty or null values.

       

      <rich:jQuery id="xprtWhtQryOn" selector="#xprtSumAnlRdo" query="click(function(){alert(jQuery(':nth(1)').attr('checked'));})"/>

      returns undefined.

       

       

      Utlimately I want to do something like this:

       

      <code>

       

      <h:selectOneRadio id="xprtSumAnlRdo" layout="lineDirection" value="#{ChannelStatusManagedBean.exporter.exportContentType}">

          <f:selectItem itemLabel="Summary" itemValue="S"/>

          <f:selectItem itemLabel="Detail" itemValue="D"/>

      </h:selectOneRadio>

      <rich:jQuery id="xprtWhtQryOn" selector="#xprtSumAnlRdo"

               query="click(function(){ if (jQuery(':checked').val() == 'A') jQuery('#xprtWhtCb).hide(); else jQuery('#xprtWhtCb).show()})"/>

       

      <h:selectManyCheckbox id="xprtWhtCb" layout="lineDirection" style="visibility:hidden;"

                    value="#{ChannelStatusManagedBean.exporter.exportWhat}">

          <f:selectItem id="xprtWhtCb-V" itemLabel="Validated" itemValue="val"/>

          <f:selectItem id="xprtWhtCb-P" itemLabel="Parent" itemValue="prnt"/>

          <f:selectItem id="xprtWhtCb-C" itemLabel="Child" itemValue="chld"/>

      </h:selectManyCheckbox>

       

       

      <code>