Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. Javascript problem causing me issues!!

Javascript problem causing me issues!!

Scheduled Pinned Locked Moved Web Development
javascripthelpphptoolsperformance
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bryant May
    wrote on last edited by
    #1

    Hi there, I am experiencing a problem which no doubt someone else has come across before but I cant work out for the life of me what the deal is with it. I have included code below for an onload function and its call that enables me to be able to call multiple functions on-load. There are two at the moment, one that calls the current date and time and puts it in a div and another that "refreshes" an AJAX call and places content in yet another div. The problem that I am having is that although both functions are being called (the second one is made in another script using a version of the same function call), only the second one is actually producing visible content (in this case a text field). However if I alert a message between the function calls both bits of content are produced as expected. The code is as follows: //The function call

    print "window.onload = callOnLoads(\"getCurDateTime\", \"\", \"\", \"\")";

    //The function definition

    function callOnLoads(pageFunction1, pageFunction2, var1, var2)
    {
    return function()
    {
    if (pageFunction1 == "getCurDateTime")
    getCurDateTime();

        //var 1 in this case is the dirToUse variable and var 2 is the userID	        
        if (pageFunction2 == "addDocType")
        	addDocType("addTypeDiv", "", "", var1, var2);      	
    }
    

    }

    The function call is made from a PHP script and the JS definition is held in a JS file. Anybody have any ideas about this? Im guessing its something to do with the speed of execution given that if I halt it with an alert it then works! As always, any help is very gratefully received. Bryant

    M 1 Reply Last reply
    0
    • B Bryant May

      Hi there, I am experiencing a problem which no doubt someone else has come across before but I cant work out for the life of me what the deal is with it. I have included code below for an onload function and its call that enables me to be able to call multiple functions on-load. There are two at the moment, one that calls the current date and time and puts it in a div and another that "refreshes" an AJAX call and places content in yet another div. The problem that I am having is that although both functions are being called (the second one is made in another script using a version of the same function call), only the second one is actually producing visible content (in this case a text field). However if I alert a message between the function calls both bits of content are produced as expected. The code is as follows: //The function call

      print "window.onload = callOnLoads(\"getCurDateTime\", \"\", \"\", \"\")";

      //The function definition

      function callOnLoads(pageFunction1, pageFunction2, var1, var2)
      {
      return function()
      {
      if (pageFunction1 == "getCurDateTime")
      getCurDateTime();

          //var 1 in this case is the dirToUse variable and var 2 is the userID	        
          if (pageFunction2 == "addDocType")
          	addDocType("addTypeDiv", "", "", var1, var2);      	
      }
      

      }

      The function call is made from a PHP script and the JS definition is held in a JS file. Anybody have any ideas about this? Im guessing its something to do with the speed of execution given that if I halt it with an alert it then works! As always, any help is very gratefully received. Bryant

      M Offline
      M Offline
      Marc Firth
      wrote on last edited by
      #2

      I don't really get your code - but if it work with a pause (alert) the you could try using php's "sleep()" or the JavaScript equivalent

      Neonlight

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups