You need to sign in to do that
Don't have an account?
mavs
help on radio button checked in javascript
Hi
I have an issue in finding if radiobutton is checked in the javascript function. Can someone please shed light on this?
Thanks
<apex:page controller="test_example"> <apex:form id="f1"> <apex:selectRadio value="{!year_num}" id="ch"> <apex:selectOption itemValue="2010" itemLabel="2010" /> <apex:selectOption itemValue="2011" itemLabel="2011" /> </apex:selectRadio> <apex:CommandLink onclick="return validate()" action="{!myaction}" target="_blank"> <font color="brown" size="3">Run Report</font> </apex:CommandLink> <script language="javascript"> function validate(){ try { var myText = "{!$Component.ch}" var t="hi "; for (i=0; i<document.f1.myText.length; i++) { if (document.f1.myText[i].checked==true) { t =t +document.f1.myText[i].value } } alert("in alert"+t); return false; } catch(e) { alert(e); return false; } } </script> </apex:form> </apex:page>
public class test_example { public String year_num{get;set;} public PageReference myaction() { return null; } }
Are you referencing the Checkbox in the right manner? Are you able to get the value of the checkbox - using the syntax in your snippet?
I think you should try referencing the checkbox element as given in the code given below:-
function beforeTextSave() {
document.getElementById('{!$component.
Example
msgpost}').value =
myEditor.getEditorHTML();
}
The page markup that follows shows the
<apex:outputText> component to which msgpost refers:
<apex:page>
<apex:outputText id="msgpost" value="Emad
is great"/>
</apex:page>
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
HI -
This is radiobutton not checkbox.
i am able to grab the value of the radiobutton, but i want to see if it is checked or not..Any idea?
This is the code i used to grab the radi button value