You need to sign in to do that
Don't have an account?

How to handle two form tags in visualforce page
Hi all,
I am working on this since hours trying many code forms, trying with java script, with ajax, etc., without success.
For a special reason I am using two form tags in my Visualforce code.
I have the same case as here described:
https://salesforce.stackexchange.com/questions/8320/how-to-handle-two-form-tags-in-visualforce-page
My javascript code looks like this (this is one of my trials):
My commandbutton looks like this:
When I click that button it should let work the form with id "cform", so that when I click on the button, the functionality behind the action "UpdateRelevantInformation" should work.
Am I missing something here? because when I put the button on the second form, "UpdateRelevantInformation" doesn't do anything, but if I put the button in the first form, where the item Relevant Information should be updated, the button works.
I would appreciate your help.
I am working on this since hours trying many code forms, trying with java script, with ajax, etc., without success.
For a special reason I am using two form tags in my Visualforce code.
I have the same case as here described:
https://salesforce.stackexchange.com/questions/8320/how-to-handle-two-form-tags-in-visualforce-page
My javascript code looks like this (this is one of my trials):
<apex:form > <script type="text/javascript"> function grabExName(){ var ex = document.getElementById('optypage:cform:new_info').value; alert(ex); } </script> <apex:actionFunction name="UpdateRelevantInformation" action="{!UpdateRelevantInformation}" reRender="out" oncomplete="grabExName();"> <apex:param name="new_info" value="" /> </apex:actionFunction> </apex:form>This is in the "<body>" part of the code.
My commandbutton looks like this:
<apex:commandlink styleclass="btn btn-primary" id="new_info" value="Save new info" action="{!UpdateRelevantInformation}" />
When I click that button it should let work the form with id "cform", so that when I click on the button, the functionality behind the action "UpdateRelevantInformation" should work.
Am I missing something here? because when I put the button on the second form, "UpdateRelevantInformation" doesn't do anything, but if I put the button in the first form, where the item Relevant Information should be updated, the button works.
I would appreciate your help.
please go through this links.
http://sfdcinpractice.com/index.php/2016/12/08/multiple-one-page/
https://th3silverlining.com/2009/10/19/multiple-forms-in-a-single-visualforce-page/
Hope this helps you.
Best Regards,
Rakesh Thota.
Since you have 2 forms,the ids may changes.We need to inspect the element and find the exact ids in 2 forms and modify the code as needed using inspect element feature of chrome browser.
For example var ex = document.getElementById('optypage:cform:new_info').value; //This again changes based on where you have kept elements.
Unfortunately visualforce can not find required id's in such case. I suggest you to use an action function as a bridge between the forms and then call this action function using button placed within the form to invoke other form actions.