
Hi Lelouch, For showing or hiding Visualforce apex:form based on a JavaScript variable and passing parameters to an Apex method, You can refer below sample code and make adjustments as per your requirement.
Vfpage code:
<apex:page controller="YourController">
<apex:form>
<script>
var isFormVisible = false;
function toggleFormVisibility() {
isFormVisible = !isFormVisible;
processParameter(isFormVisible);
}
</script>
<input type="button" value="Toggle Form" onclick="toggleFormVisibility();" />
<apex:outputPanel id="formBlock">
<apex:form rendered="{!showForm}">
<!-- Form fields -->
<apex:inputText value="{!yourValue}" label="Your Value" />
<apex:commandButton value="Submit" />
</apex:form>
</apex:outputPanel>
<apex:actionFunction name="processParameter" action="{!processFormVisibility}"
rerender="formBlock">
<apex:param name="paramValue" value="" assignTo="{!isFormVisible}" />
</apex:actionFunction>
</apex:form>
</apex:page>
The above sample code creates a page with a hidden form. Clicking the "Toggle Form" button makes the form appear or disappear. The "Your Value" field is for input, which you can customize for your specific use. Related:https://salesforce.stackexchange.com/questions/327394/how-to-show-hide-a-visualforce-component-using-the-rendered-attribute https://www.forcetalks.com/salesforce-topic/can-we-hide-particular-portion-of-visualpage-on-click-of-button-using-render-and-rerender/ If this information helps, please mark the answer as best. Thank youController class:
public class YourController {
public Boolean showForm { get; set; }
public String yourValue { get; set; }
public YourController() {
showForm = false;
}
// Server-side method to toggle form visibility
public PageReference processFormVisibility() {
showForm = isFormVisible;
return null;
}
}