Jump to content

select data from php fetch array to javascript popup div


funbinod

Recommended Posts

I have columns from some rows of a MySQL table using php.

while ($qr = $qq->fetch_assoc()) {    echo '<a id="email">'.$qr['email'].'</a>';}

there are multiple rows. but when I click and any of the derived emails, I want that email to be displayed on the popuped div

	$("#email").click(function(e) {		$("body").append("<div id=pop><div id=popin><br /><br /><input id=emaill type=text value='<?php echo $aemail; ?>' /><br /><br /><input type=button id=close value=CLOSE /></div></div>");		$('#popin').effect('slide', {easing:'easeInOutElastic'},3000);		$('#emaill').focus();   	});

I don't what exactly I've to do for this but I've kept the javascript outside the while loop and its not working.

 

can anyone guide me for this???? :(

 

 

thanks in advance...

Link to comment
Share on other sites

thank u for the quick reply. I've tried using class also. but its not working either... :(

 

edit:

moreover using class opens popup div for all the emails...

Edited by funbinod
Link to comment
Share on other sites

It should work if you do it right, I'm not sure what you did. You shouldn't have PHP write out the email address in that Javascript code though, unless you want to use the same email address for every pop up. If you're trying to fill in the email address associated with the link then put the email address as a data attribute on the anchor tag and get it in the click handler to fill in. I'm not sure exactly what you're trying to accomplish or what the HTML ends up looking like though. If you run that click handler multiple times then it's also going to end up appending elements with the same ID to the page.

Link to comment
Share on other sites

 

If you're trying to fill in the email address associated with the link then put the email address as a data attribute on the anchor tag and get it in the click handler to fill in

 

i'm doing this. but the problem is that I want the email address on a "div" on the "same page" that is appended on click event, not on a "new popup window". I know how to use "data attribute on the anchor tag" to a new window, as u suggested. but I don't know how to do that on the same page.. will u please guide me to this...??? :(

Link to comment
Share on other sites

  $n = 0;  while ($qr = $qq->fetch_assoc()) {	  $n++;          <a class="email" id="email'.$n.'">'.$aemail.'</a>;}
		<script>		$("#email<?php echo $n; ?>").click(function(e) {			$("body").append("<div id=pop><div id=popin><br /><br /><input id=emaill type=text value='<?php echo $aemail; ?>' /><br /><br /><input type=button id='close' value=CLOSE /></div></div>");			$("#popin").effect("slide", {easing:"easeInOutElastic"},3000);			$("#emaill").focus();   		});		</script>

the javascript inside while loop

 

and this worked now...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...