0

Hello all need help to call the function on page2 fundemo() based on the button click on page 1 js ABSENCE APPROVAL

Page1.html
<script>
  $.getScript(path + "js/Page1.js");
</script>

<p id="currentPage"> </p>


<div class="hr">
<input type="button" id="hr" class="appButton" value="HR" onclick="funchr();" />
<input type="button" id="crm" class="appButton" value="CRM" onclick="funccrm();"/>
</div>
 <div id="show1" style="display:none;">
 <input type="text" id="searchcustom">
 <input type="submit" id="sebutton" value="search" onclick="fus();">
 </div>
<div id="placehere">

</div>
<ul id="page1display"> </ul>
<div class="empl"> <ul id="mydemo1"> </ul> </div>
<ul id="empdetdemo"> </ul>
<input type="button" id="backButtonPage1" class="backbutton" value="BACK" onclick="currentPage.back();" />

Page2.html
<script>
  $.getScript(path + "js/Page2.js");
</script>

<p id="currentPage"> </p>

Page2.js

currentPage={};

currentPage.init = function() {
 WL.Logger.debug("Page2 :: init");
};
currentPage.back = function(){
 WL.Logger.debug("Page2 :: back");
 $("#pagePort").load(pagesHistory.pop());
};

function fundemo()
{
  alert("HAI");
}

Page1.js
currentPage={};

currentPage.init = function() {
 WL.Logger.debug("Page1 :: init");
};
currentPage.back = function(){
 WL.Logger.debug("Page1 :: back");
 $("#pagePort").load(pagesHistory.pop());
};

function funccrm()
{
 $("#pagePort").load(path + "pages/Page3.html"); 
}

function funchr()
{   $( ".hr" ).remove();
 
    
    if(person_role == "Y")
   {
    var btn = document.createElement("BUTTON");        
    var t = document.createTextNode("ABSENCE APPROVAL");
    btn.appendChild(t);                                
    btn.setAttribute("id","absapr");
    document.body.appendChild(btn);
   }
    
    
    $('#absapr').click(function(){
       $("#pagePort").load(path + "pages/Page2.html"); 
      }
Idan Adar
  • 43,235
  • 10
  • 45
  • 83
  • So if my understanding is correct, if I click on button on page one, I'll be redirected to page two and on load you want to call this function. Am I right? – Rajesh Nov 06 '15 at 08:05
  • yes exactly right i wanna run the page2 function on page1 button click – Vikram Srinivasan Nov 06 '15 at 08:12
  • You can set query parameter if button is clicked and then on page two, check for this parameter. If available, execute function. – Rajesh Nov 06 '15 at 08:17
  • Check this for [reference](http://stackoverflow.com/questions/5999118/add-or-update-query-string-parameter) – Rajesh Nov 06 '15 at 08:47
  • cant understand there is no url or nothing just am working with multipage application by loading pages into main page using div and need to call page 2 function on page 1 button click – Vikram Srinivasan Nov 06 '15 at 09:55
  • If that is the case, you can use a callback function. When you load Page Two, if button was clicked, pass a function that should be executed. else send a blank function. – Rajesh Nov 06 '15 at 10:27

0 Answers0