You need to sign in to do that
Don't have an account?
Arvind010
Checkbox validation
I have a check box in my visual force page.If that check box is checked,an alert message should be displayed.
I tried giving the condition,
Above mentioned conditions are not working.I dont know how to give the condition.Please provide me the solution.
Code:
<apex:inputCheckbox id="box1" value="{!accepted}" />
Code:
alert(document.getElementById("box1").value);
and
document.formname.box1.checked
<apex:inputCheckbox onclick="if(this.checked) alert('boo!');"> </apex:inputCheckbox>
R.
Message Edited by Arvind010 on 08-11-2008 09:16 PM
the solution could be something like:-
<input type="checkbox" id="chkBox"/>
<button onclick="if (chkBox.checked) alert('checked');" >click me</button>
Not tried this but the logic should work.
This will alert the id of the checkbox component. It doesn't do anything useful but you can see now how you can use getElementById to get the checkbox and check whether it has been selected or not.
Message Edited by jwetzler on 08-12-2008 07:49 AM
do this:-
<apex:inputCheckbox id="box1" />
<apex:commandButton value="Click Here" action="{!DoAction}" onclick="alert(document.getElementById('{!$Component.box1}').checked)"/>