[eluser]cip6791[/eluser]
Hello,
I have a small issue with something I'm trying to do.
This is in my view. Not sure if this is the proper way to do this. I'm basically getting the content of the website for the home page. For each of the results I want a button that will get a little additional info for each item in a different div. The code works if I leave xmlhttp.open("GET","http://mysite.com/index.php/home/show/9/comm", true); the way it is. Since I need the id and the category in the url (9/comm) I tried doing this xmlhttp.open("GET","http://mysite.com/index.php/home/show/<?php echo $homeitem->id; ?>/<?php echo $homeitem->cat; ?>", true); but that doesn't work. Any help is appreciated. Is it ok to load the loadXMLDoc function for each of the items? Thank you.
Code:
<?php foreach($sqlquery->result() as $homeitem; ?>
<p><?php echo $homeitem->name; ?></p>
|script type="text/javascript"|
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv")[removed]=xmlhttp.responseText;
}
}
xmlhttp.open("GET","http://mysite.com/index.php/home/show/9/comm", true);
xmlhttp.send();
}
|/script|
<button>Change</button>
<php endforeach; ?>
<div id="myDiv">Change this!</div>