function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TejTej 

Onclick in select radio component --URGENT

Hi,

I have a visualforce page from where the users can upload/fax documents.

the above two are radio buttons 

 

in my visualforce page they look like this 

 

<apex:selectRadio value="{!action}" onclick="YAHOO.force.com.showMe();" > 

         <apex:selectOptions value="{!listofactions}" />

</apex:selectRadio> 

 

the problem is the pop up is showing for both the radio buttons but i want to show the popup only when the action= "Upload"

 

is there a way i can put a IF statement in onclick or any other way 

Plz help

Best Answer chosen by Admin (Salesforce Developers) 
TheSwamiTheSwami

How about this:

 

<apex:page controller="SelectController">
<script type="text/javascript">
function doSomething(value) {
    if (value == 'Upload')
        alert('doing something');
}
</script>
    <apex:form >
        <apex:selectRadio value="{!action}" id="theCommand" onclick="doSomething(this.value)" > 
            <apex:selectOptions value="{!listofactions}"/>
        </apex:selectRadio> 
    </apex:form>
</apex:page>

 

This assumes the value of the select option is "Upload" but I think you could do what you need from this example.

 

Hope it helps. 

All Answers

JesseAJesseA

My javascipt is subpar but I would look to see if you can add an inline java if statement. ie onclick="javaIf(Yahoo.force.com.showMe();)"

TheSwamiTheSwami

How about this:

 

<apex:page controller="SelectController">
<script type="text/javascript">
function doSomething(value) {
    if (value == 'Upload')
        alert('doing something');
}
</script>
    <apex:form >
        <apex:selectRadio value="{!action}" id="theCommand" onclick="doSomething(this.value)" > 
            <apex:selectOptions value="{!listofactions}"/>
        </apex:selectRadio> 
    </apex:form>
</apex:page>

 

This assumes the value of the select option is "Upload" but I think you could do what you need from this example.

 

Hope it helps. 

This was selected as the best answer
TejTej

Thanks a lot, worked like a charm :)