1
<apex:page > 
<html>
    <form method="get" action="https://cs6.salesforce.com/00ON0000000FOHS" >
        <b>Enter Text</b><input type="text" id="pv2" name="pv2"/>
        <input type="button" value="Report Generation" class="button" onclick="samepage();"/>
   </form>
<script>
Function samepage()
{
Var text =Document.getElementById("pv2").value;
Var Data= text;
  $.ajax({
      type: "POST",
      url: "https://cs6.salesforce.com/00ON0000000FOHS" // form action url
      data: Data,
      cache: false,
      success: function(output)
      {
Document.getElementById("output").innerHTML= output;
      }     
      });
}
</script>
This dynamic div
<div id="output" style="border:1px solid;width:1000px;height:500px;">
</div>
</html>
</apex:page>

I need in such a way that half of the page will be static and another half of the page will be dynamic .will change according to user input

for this i had wrote one page it is not returning the div tag?

when i keep input type as submit it resulting the results in new window? i need that in the same page .how can i do that is this the correct way? help me out

  • Hi,u can use <apex:actionfunction/> for this one – Sunny Dec 24 '13 at 12:00
  • And one more thing u r forgot to include JQuery as u r using $.ajax....also u r using same url as u mentioned above – Sunny Dec 24 '13 at 12:01
1

For your particular case, there's really no need to use jquery async call (at least not in the terms of 'manually' building your async request; solution using commandButton will still generate async request 'under the hood', but you won't need to handcode it). My suggestion would be to use custom controller in combination with apex:outputPanel refreshed upon each call to apex:commandButton's action (specified through commandButton's rerender attribute).

In this case your VF page might look something like:

<apex:page controller="YourReportPageController" > 
    <apex:form >
        <b>Enter Text</b>

        <apex:inputText id="pv2" value="{!pv2Text}" />
        <apex:commandButton value="Report Generation" action="{!generateReport}" rerender="reportOutputDiv" />

        This dynamic div
        <apex:outputPanel id="reportOutputDiv" layout="block" style="border:1px solid;width:1000px;height:500px;">
            <apex:outputText value="{!htmlOutput}" />
        </apex:outputPanel>
   </apex:form>

</apex:page>


...with YourReportPageController looking like this:

public with sharing class YourReportPageController
{
    public string pv2Text { get; set; }
    public string htmlOutput { get; set; }

    public YourReportPageController()
    {
        // whatever logic you need to do on load
    }

    public PageReference generateReport()
    {
        // do whatever you need to do to generate report
        // ...
        // if you need to use value from the inputField,
        // simply access it via pv2Text variable

        // Assign report output value to htmlOutput variable
        htmlOutput = "bla bla";

        // return null in order to avoid redirect (stay on the same page)
        return null;
    }
}


Hope it helps.

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.