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
Major1507Major1507 

Radio button and Query

I have two radio buttons,
1-Contact, 2-Account.  
When i click on contact a search query should run on contact and when i click account the search query should run on account.   I need this to work on lightning.

Any help is appreciated.
Ashif KhanAshif Khan
Try This 
 
<!--yourComp.cmp-->
<aura:component>
    <aura:attribute  name='SelectedRadioButton' type='String' default='Account' />
    <lightning:input type="radio" label="Account" name="Search" value="Account" onchange="{!c.myAction}"  checked="true"/>
    <lightning:input type="radio" label="Contact" name="Search" value="Contact" onchange="{!c.myAction}"/>
    <Button onclick='{!c.search}'>Search</Button>
</aura:component>
 
/**JS COntroller **/

({
	myAction : function(component, event, helper) {
	    var SelectedRadioButton = event.getSource().get("v.label");
    component.set('v.SelectedRadioButton',SelectedRadioButton);
    },
    search: function(component, event, helper) {
    var SelectedRadioButton=component.get('v.SelectedRadioButton');
        if(SelectedRadioButton=='Account'){
            //Account Apex Calling
        }else if(SelectedRadioButton=='Contact'){
            //Contact Apex Calling
        }else{
            
        }
    }
})

 
Major1507Major1507
Can you please show the apex class and how you are calling in JS Controller without using helper?