You need to sign in to do that
Don't have an account?
bujji
How to get radio button label when i click on the button in salesforce lightning controller
Hi,
I want to create an account when the button clicked in the lightnining component. I am able to do it successfully but the real problem i am facing is i have a field with four radio buttons, i have to save the user select radio button label into this field. How to acheive this. Please see my code. Thanks.
<form class="slds-form--stacked">
<div class="slds-form-element slds-is-required">
<div class="slds-form-element__control">
<ui:inputText aura:id="accname" label="Account Name"
class="slds-input"
labelClass="slds-form-element__label"
value="{!v.newAccount.Name}"
required="true"/>
</div>
</div>
<b>Radio Buttons - Group</b>
<ui:inputRadio aura:id="r0" name="others" label="Test1" change="{!c.onGroup}" />
<ui:inputRadio aura:id="r1" name="others" label="Test2" change="{!c.onGroup}" value="{!v.newAccount.Interest}"/>
<ui:inputRadio aura:id="r2" name="others" label="Test3" change="{!c.onGroup}" />
<ui:inputRadio aura:id="r3" name="others" label="Test4" change="{!c.onGroup}" />
<b>Selected Items:</b>
<p><ui:outputText class="result" aura:id="radioGroupResult" value="" /></p>
<div class="slds-form-element">
<ui:button label="Save Account"
class="slds-button slds-button--brand"
press="{!c.clickAccountCreate}"/>
</div>
</form>
---------------
clickAccountCreate: function(component, event, helper) {
// Create the new Account
var newAccount = component.get("v.newAccount");
console.log(component.find('others'));
//newAccount.Website = event.source.get("v.label");
console.log("Create Account: " + JSON.stringify(newAccount));
helper.createAccount(component, newAccount);
},
I want to create an account when the button clicked in the lightnining component. I am able to do it successfully but the real problem i am facing is i have a field with four radio buttons, i have to save the user select radio button label into this field. How to acheive this. Please see my code. Thanks.
<form class="slds-form--stacked">
<div class="slds-form-element slds-is-required">
<div class="slds-form-element__control">
<ui:inputText aura:id="accname" label="Account Name"
class="slds-input"
labelClass="slds-form-element__label"
value="{!v.newAccount.Name}"
required="true"/>
</div>
</div>
<b>Radio Buttons - Group</b>
<ui:inputRadio aura:id="r0" name="others" label="Test1" change="{!c.onGroup}" />
<ui:inputRadio aura:id="r1" name="others" label="Test2" change="{!c.onGroup}" value="{!v.newAccount.Interest}"/>
<ui:inputRadio aura:id="r2" name="others" label="Test3" change="{!c.onGroup}" />
<ui:inputRadio aura:id="r3" name="others" label="Test4" change="{!c.onGroup}" />
<b>Selected Items:</b>
<p><ui:outputText class="result" aura:id="radioGroupResult" value="" /></p>
<div class="slds-form-element">
<ui:button label="Save Account"
class="slds-button slds-button--brand"
press="{!c.clickAccountCreate}"/>
</div>
</form>
---------------
clickAccountCreate: function(component, event, helper) {
// Create the new Account
var newAccount = component.get("v.newAccount");
console.log(component.find('others'));
//newAccount.Website = event.source.get("v.label");
console.log("Create Account: " + JSON.stringify(newAccount));
helper.createAccount(component, newAccount);
},
first create a aura:attribute with string type on your component
add js controller function on the change of the radio button lable value is store in the storeRadioValue attribute so on the button click you can get the lable value from attribute by using
component..get("v.storeRadioValue");
i hope it helps you.
Let me inform if it helps you and kindly mark it best answer if it helps you so it make proper soltuions for others
thanks
http://sfdcmonkey.com (http://sfdcmonkey.com )