Jump to content

Using ajax instead of normal js in a php loop?


Fenhopi

Recommended Posts

Hi, I'm aware that there are some difficulties with using javascript in php loops because of the client side and server side work that's being done.

Anyways, here's what I got:

Code:


function alertBox() {
document.sendform.to2.value = document.getElementById('test3').value;  
document.sendform.to.value = document.getElementById('test4').value;
e.style.display="none";  
}
while ($row = mysql_fetch_array($getRecord)) {
	$TheirProfilePicture = $row['profilepicture'];
	$mysock = getimagesize("http://face2blog.comlu.com/images/uploads/$TheirProfilePicture?time=time()");?>
	<li><a href="#" onClick="alertBox();" id="test"><img src="http://face2blog.comlu.com/images/uploads/<? echo $TheirProfilePicture ?>?time=<?php echo time(); ?>" <? echo imageResize($mysock[0], $mysock[1], 45); ?> /> <font color="grey" size="3"><?php echo $row['firstname']; ?> <?php echo $row['lastname']; ?></font><input type="hidden" id="test3" value="<?php echo $row['firstname']; ?> <?php echo $row['lastname']; ?>"><input type="hidden" id="test4" value="<?php echo $row['username']; ?>"></a></li>

<?php } 

 

Please ignore the lach of script tags, I'm just pasting in what's relevant.

 

This is the code of my autosuggest search thingy. When a user clicks one of the suggestions I'd like alertbox(); to get the info of the one I picked, not the last result that was looped.

Is there a way or a trick that I could do to make this work with ajax?

 

Thank you in advance!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.