Jump to content

Troubles with a javascript function inside 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:

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?

 

Thank you in advance!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.