littlehelp Posted January 17, 2009 Share Posted January 17, 2009 ok i have information from a database that i wish to switch between there are 6 items on the bottom of the page that onclick the top item (it is alone) needs to be updated to show the content of the item that is selected. I just need an example of taking the information from a db and switching the content of the top item . so therefor items 1 2 3 4 5 6 are on the bottom with a pic of them and then the pic is clicked and it goes up top to be shown off with basic information. I hope i have explained this good enough, i am currently working on the code for it but am struggling fiercely with it, any examples would be greatly appreciated.(i can do the php easily enough only the ajax is making me go crazy) Thanks in advance for any help. Quote Link to comment Share on other sites More sharing options...
dawsba Posted January 17, 2009 Share Posted January 17, 2009 use this in your onclick event as onclick="sndReq('mydivthingymebob','pointstomyphp.php?thisvar=something')" <script> function createRequestObject() { var ro; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ ro = new ActiveXObject("Microsoft.XMLHTTP"); }else{ ro = new XMLHttpRequest(); } return ro; } var http = createRequestObject(); var returnDiv function sndReq(divRet,file) { var date = new Date(); var timestamp = date.getTime(); returnDiv = divRet; http.open('get', file+'&time='+timestamp); http.onreadystatechange = handleResponse; http.send(null); } function handleResponse() { if(http.readyState == 4){ var response = http.responseText; document.getElementById(returnDiv).innerHTML = response; } } function resetdefault(a,b) { document.getElementById(a).innerHTML = document.getElementById(b).innerHTML; } </script> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.