You need to sign in to do that
Don't have an account?
MMA_FORCE
Can I do checkbox in VF this way????
Hi:
I have a checkbox named advanceFilter and if checked would like an entire row to appear...
But somehow it is not working with my current statement :
<td>AdvanceFilter<input type="checkbox" name="AdvanceFilter" id="af"/></td> </tr> <tr><td> <input type="checkbox" name="AdvanceFilter" rendered="{!$Component.theform.AdvanceFilter='true'}"/> </td></tr>
{!$Component.theform.the_checkbox} generates the id of the input checkbox on the page.
If you want to get the value of the checkbox, you'll need something in Javascript like:
document.getElementById('{!$Component.theform.the_checkbox}').value
All Answers
Is there a way to show a table based off a checkbox? Does anyone have an example of this...
Thanks
Thank You Anand...
So I have done this but does not seem to be working what am I doing incorrect?
<td> AdvanceFilter: <input type="checkbox" name="the_checkbox" value="ok" /> <apex:actionSupport event="onClick" reRender="{!$Component.theform.hello}" status="testStatus" /> </td> </tr> <apex:actionStatus id="testStatus" startText="Loading" /> <apex:actionRegion rendered="{!$Component.theform.the_checkbox.value='ok'}" > <table id="hello"> <tr> <td>meal: <input type="checkbox" name="meal" value="salad" /></td> </tr> </table> </apex:actionRegion>
actionsupport has to be embedded inside another apex component to have any effect.
You'll need to change your regular HTML checkbox to an inputCheckbox component and nest the actionsupport inside that.
Yeah but for an inputcheckbox the VF Tag I need to place in the value and bind it to a field...
This is a reporting tool I am creating so I can not have it bind to any field but itself...
How would I go around that?
Thank you for that Bob...
But now that I did that, nothing happens:
<td> AdvanceFilter: <apex:inputCheckbox id="the_checkbox" title="Advance Filter"/> <apex:actionSupport event="onClick" reRender="{!$Component.theform.hello}" status="testStatus" /> </td> </tr> <apex:actionStatus id="testStatus" startText="Loading" /> <apex:actionRegion rendered="{!$Component.theform.the_checkbox}" > <table id="hello"> <tr> <td>meal: <apex:inputCheckbox id="meal" /></td> </tr> </table> </apex:actionRegion>
ok... So now I did this: and nothing happen??? am I missing something
<td> <apex:actionSupport event="onClick" reRender="{!$Component.theform.hello}" status="testStatus" > AdvanceFilter: <apex:inputCheckbox id="the_checkbox" title="Advance Filter"/> </apex:actionSupport> </td> </tr> <apex:actionStatus id="testStatus" startText="Loading" /> <apex:actionRegion rendered="{!$Component.theform.the_checkbox}" > <table id="hello"> <tr> <td>meal: <apex:inputCheckbox id="meal" /></td> </tr> </table> </apex:actionRegion>
I even tried:nothing???
You still haven't nested actionsupport inside your inputcheckbox. You've nested inputcheckbox inside your actionsupport.
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionSupport.htm
As you can see, actionsupport goes inside the component that you wish to add the behaviour to. In the linked example, its adding actionsupport to the outputpanel.
Thank you ... I did do that and I see it work with the exception that it does not show the table??
<apex:outputpanel id="counter"> <apex:inputCheckbox id="the_checkbox"/> <apex:actionSupport event="onclick" rerender="counter" status="counterStatus"/> <apex:actionStatus id="counterStatus" startText=" (loading filters...)" /> <apex:actionRegion rendered="{!$Component.theform.the_checkbox}"> <table id="hello"> <tr> <td>Special Education: <apex:inputCheckbox id="specialeducation" /></td> <td>Student Free Lunch: <apex:inputCheckbox id="StudentFreeLunch" /></td> </tr> </table> </apex:actionRegion> </apex:outputpanel> </td> </tr>
All I want it to do is simple:
If the_checkbox=true which is if the user clicks on it and it is checked
show the table
if not then do not show it...
I tried:
{!$Component.theform.the_checkbox='true'}
did not work?
How can u check if the checkbox is true or checked to render that region ?
{!$Component.theform.the_checkbox} generates the id of the input checkbox on the page.
If you want to get the value of the checkbox, you'll need something in Javascript like:
document.getElementById('{!$Component.theform.the_checkbox}').value