2

So I was trying to create a VF page which on clicking Save will re-direct the page to google form and following is the code I am using. This is currently loading the page back to VF on edit mode.

<script type="text/javascript">
   function navigate(){
      var desc=document.getElementById('{!$Component.thepage.theform.thepgblk.VF_buttons.thepgsection.desc}');
      alert(desc);
      var url='https://docs.google.com/a/forms/d/112GYhKbx5Ux833UDI_dEA1yL2eHuW0pr5blOymLoRsg/viewform?entry.399734918=&entry.571044671='+desc+'&entry.488162040&entry.1220858109=TEST+SALES&entry.449060360&entry.776835233&entry.754748200&entry.1408822280&entry.315413522&entry.1366373962=Just+a+Test&entry.1716955237=Step+1+%0AStep+2%0AStep+3';
      alert(url);
      window.location.href=url;
      return url;
   }
</script>

  <apex:form id="theform"> 
        <apex:pageBlock id="thepgblk">
        <apex:pageBlockButtons id="VF_buttons" location="top"> 
        <apex:commandButton onclick="navigate();" value="Save"/>
        <apex:commandButton onclick="window.close();" value="Close" />
        </apex:pageBlockButtons>

        <apex:pageBlockSection id="thepgsection">
          <apex:inputfield id="desc" value="{!escalation.Problem_Description__c}"/>
        </apex:pageBlockSection>
        </apex:pageBlock>
</apex:form>
</apex:page>
  • What part isn't working? Where are you stuck? How can we help? Dumping code with no description of the problem is not likely to elicit much help from the community. – Mark Pond May 20 '15 at 21:50
  • Ya I guess I was unclear ! this is my first Post here in the community will keep that in mind ! Thanks Mark and I got helped btw. – Sanjay May 20 '15 at 22:09
  • If you got helped, perhaps update the question and answer it so we can all learn, or delete the question. Thanks! – DavidSchach May 20 '15 at 22:33
2

When you click on the save button it just sends the form data/reloads the current page so try to replace the save command button with below element:

<input onclick="navigate();" value="Save" class="btn" title="Save" name="save" type="button" />

Hope this will help you.

  • Great! One more thing, I don't see any sense using apex:form there so remove it and replace all other buttons with pure html buttons. – Ruslan Vekua May 20 '15 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.