Jump to content


ajax and php loading from a db


3 replies to this topic

#1 xmlhelpneeded

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 09 January 2009 - 07:27 PM

ok i am trying to make an items box using ajax and then loading the items from a db i am a little confused about how to do this, something like this...
function loadItems()
{

	if(document.getElementById("itemBox").style.display == "block")
	{
		document.getElementById("itemBox").style.display = "none";
		
	}
	else
	{
		document.getElementById("itemBox").style.display = "block";
	//i should call something here and am lost as to what to call to get the items from lets say loaditems.php
	}
	return false;
}

then i imagine i need to call my php file that is loading my items from the db or something i am a little confused any help would be appreciated

Edited by xmlhelpneeded, 09 January 2009 - 07:30 PM.


#2 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 10 January 2009 - 04:21 PM

Look at your code again....

Your asking the js if your "itemBox" is double equivalent to block, if it is then you don't want to display it, if it isn't, then you want to dispay it? It cancels it out. the first if statement. I may be missing something.

#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 10 January 2009 - 06:33 PM

It's kind of like a show/hide switch. I'm assuming that when the button is pressed a second time it would hide the box, whereas the first call to the function would show the box and load the items.

http://www.sitepoint...e-command-ajax/
:google:

#4 xmlhelpneeded

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 11 January 2009 - 04:14 PM

View Postrc69, on Jan 10 2009, 06:33 PM, said:

It's kind of like a show/hide switch. I'm assuming that when the button is pressed a second time it would hide the box, whereas the first call to the function would show the box and load the items.

http://www.sitepoint...e-command-ajax/
:google:
That is correct i actually fixed the problem myself but thank you anyways





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users