function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nisar AhmedNisar Ahmed 

Unable to submit a form while redirecting from a VF page.

Hi All,

 

I have two VF pages 'A' and 'B'.

Page 'A' contains a textbox and 'Search' button, on clicking 'Search' button it directs us to Page 'B' with the search string as a parameter.

Page 'B' contains a 'Go Back' button, on clicking 'Go Back' button it redirects us back to Page 'A' with the same search string as a parameter. I am even able to pass that string in the textbox present in Page 'A'.

 

Problem:

After passing the string to the textbox, I am unable to click the 'Search' button or (submit the form) so that i can get back the search results when we click on the 'Go Back' button on page 'B'.

Here is the script that I have written on Page 'A' :

 

/* Script code */
function gup( name )
{
        name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
        var regexS = "[\\?&]"+name+"=([^&#]*)";
        var regex = new RegExp( regexS );
        var results = regex.exec( window.location.href );
        if( results == null )
            return "";
        else
            return results[1];
}

function Submitfunction()
{
        var btnSubmitTags = document.getElementById('j_id0:form1:searchsubmit');
        var store_str = gup( 'StoreSearch' );
        oFormObject = document.forms['j_id0:form1'];
        oFormElement = oFormObject.elements['addressInput'];
        if(store_str.length > 0){
            oFormElement.value = store_str;
        }
        btnSubmitTags.click();

}
/* Script code */

 Please let me know if you have any idea about this problem or where I have went wrong.

 

 

bob_buzzardbob_buzzard

Have you tied your submitFunction to an onload handler or similar to actually fire when Page A is rendered?