Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2009
    Location
    Chicago, IL
    Posts
    169
    Thanks
    26
    Thanked 3 Times in 3 Posts

    Problem with <body onLoad>

    The following script works when I load the page. However, I have a form that, when submitted, doesn't run the script again. I have a page called restaurants.php. Submitting the form goes to restaurants.php?a=edit. This second loading of restaurants.php doesn't re-call the 'createAutoComplete' function again. Instead, it shows the output from its first calling. Any ideas? Here is some code...

    Code:
    <body onLoad='createAutoComplete(<?php echo $restString; ?>);'>
    Last edited by wldrumstcs; 07-20-2009 at 01:58 AM.

  • #2
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    Well it surely doesn't remember the output between HTTP requests, does it? Can you show the whole page?

  • #3
    Regular Coder
    Join Date
    Jul 2009
    Location
    Chicago, IL
    Posts
    169
    Thanks
    26
    Thanked 3 Times in 3 Posts
    Code:
    if($authenticate_user)
    {
    	$sql = "SELECT distinct(restaurant) FROM restjournal WHERE userid='$_COOKIE[id]'";
    	$result = mysql_query($sql);
    	while($row = mysql_fetch_array($result))
    	{ 
    	   $restString .= $row["restaurant"] . ",";
    	}
    	// get rid of last ,
    	$restString = substr_replace($restString,'"',-1);
    
    	echo $restString;
    }
    When $restString outputs, it's not being updated for some reason.
    Last edited by wldrumstcs; 07-20-2009 at 01:50 AM.

  • #4
    Regular Coder
    Join Date
    Jul 2009
    Location
    Chicago, IL
    Posts
    169
    Thanks
    26
    Thanked 3 Times in 3 Posts
    Nevermind, I just realized that I am pulling the SQL info before I edit the entries. Pulling the SQL info after that solves it. I am an idiot.

  • #5
    GŁtkodierer
    Join Date
    Apr 2009
    Posts
    2,127
    Thanks
    1
    Thanked 426 Times in 424 Posts
    What do you mean it's not being updated? Are we talking about an AJAX call here? Please describe in greater detail what exactly should happen, what exactly does happen, and better yet link to the page.

    And are you sure this isn't rather a PHP problem than a Javascript one?

    Edit: Alright, you solved it. And it definitely has been in the wrong forum.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •