Skip to main content
Hi,

I have a special discount , However thing is if that discount field gets applied all other fields should get disabled.

I am thinking to apply a checkbox "special discount". Once that gets filled in. all other fields gets disabled and only special discount text field gets enabled.

All fields are lightning input

How can i do it in lightning ?
4 件の回答
  1. 2019年4月20日 3:32
    HI Sid,

    Can you try below below to hide lightning:input fileds.

    Lightning Component Code:

    <aura:component implements="flexipage:availableForAllPageTypes" access="global" >

    <aura:attribute name="acc" type="Account" default="{ 'sobjectType': 'Account' }"/>

    <aura:attribute name="hide" type="string" default="true"/>

    <form>

    <lightning:input name="Name" label="Name" aura:id="accountName" value="{!v.acc.Name}" onchange="{!c.disableFields}"/>

    <aura:if isTrue="{!v.hide}">

    <lightning:input name="First Name" label="First Name" value="{!v.acc.firstName}"/>

    <Lightning:input name="Last Name" label="Last Name" value="{!v.acc.lastName}"/>

    </aura:if>

    </form>

    </aura:component>

     

    js.cotroller Code

    ({

    disableFields : function(component, event, helper) {

    var val = component.find("accountName").get("v.value");

    if(val != null){

    component.set('v.hide' , "false");

    }

    }

    })

    Let me know if it didnt work for you.

0/9000