MikeDXUNL Posted February 2, 2008 Share Posted February 2, 2008 var xmlHttp function readmore(str) { xmlHttp=GetXmlHttpObject(); if (xmlHttp==null) { alert ("Your browser does not support AJAX!"); return; } var url="ajax/findnews.php"; url=url+"?newsid="+str; xmlHttp.onreadystatechange=stateChanged; xmlHttp.open("GET",url,true); xmlHttp.send(null); } function stateChanged() { if (xmlHttp.readyState==4) { document.getElementById("full").innerHTML=xmlHttp.responseText; } } i tried: ("full"+str) ("full"+str"") and I cant seem that line to equal full plus the str help please? Thanks, Mike Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 2, 2008 Share Posted February 2, 2008 What? - That's All I Can Say Your going to have to explain what your wanting or what your having problems with or errors or something. Quote Link to comment Share on other sites More sharing options...
MikeDXUNL Posted February 2, 2008 Author Share Posted February 2, 2008 in my html I have a line saying: <div id="full<?php echo $news['newsid']; ?>"> </div> say $news['newsid'] is 15 there is a link called Read More: <div id="readmore<?php echo $news['newsid'];?>"><a href="#" onClick="readmore('<?php echo $news['newsid']; ?>'); return false;">Read More</a></div> When they click Read More, It access the function and grabs Info from a PHP file. Then whatever is returned, should be placed in <div id="full<?php echo $news['newsid']; ?>"> </div> but I can't figure out in the JS: document.getElementById("full").innerHTML=xmlHttp.responseText; how to make full+str work so it will say "getElementByID("full15") technically Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted February 4, 2008 Share Posted February 4, 2008 You need to set the entire id with a parameter and then this will work. Example: <script language="javascript"> function readmore(from) { document.getElementById(from).innerHTML = xmlHttp.responseText; } </script> <div id="readmore<?php echo $news['newsid'];?>"><a href="#" onClick="readmore('<?php echo $news['newsid']; ?>'); return false;">Read More</a></div> Do something to this extent and I think it will work the way you want it to. 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.