gpt4 book ai didi

salesforce - 在visualforce中选中复选框后显示文本字段

转载 作者:行者123 更新时间:2023-12-04 10:28:41 24 4
gpt4 key购买 nike

我有一个要求,即在选中复选框时必须使文本字段可编辑或呈现,我该如何实现?

最佳答案

这是一个严格的 Visualforce 代码示例,也可以正常工作:

<apex:pageBlock id="theBlock">
<apex:inputCheckbox value="{!theSObject.CheckBox__c}">
<apex:actionSupport event="onchange" rerender="theBlock"/>
</apex:inputCheckbox>

<apex:inputText value="{!theSObject.TextField__c}" disabled="false" rendered="{!(theSObject.CheckBox__c == true)}"/>
<apex:inputText value="{!theSObject.TextField__c}" disabled="true" rendered="{!(theSObject.CheckBox__c != true)}"/>

<!-- Or to simply have a field that appears only when the box is checked -->
<apex:inputText value="{!theSObject.TextField__c}" rendered="{!(theSObject.CheckBox__c == true)}"/>
</apex:pageBlock>

除此之外,如果您希望在 Apex 中进行进一步处理,您可以在 Action 支持中添加一个 Action ,如下所示:
<apex:actionSupport event="onchange" action="{!myMethod}" rerender="theBlock"/>

希望有帮助

关于salesforce - 在visualforce中选中复选框后显示文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8578748/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com