link open jquery function

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 6191 Views - Last Post: 23 December 2012 - 08:06 AM

#16 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3331
  • View blog
  • Posts: 11,281
  • Joined: 12-December 12

Re: link open jquery function

Posted 23 December 2012 - 03:18 AM

<?php
$num = 3;

echo"<button type='button' id='like_button' class='button' name='like_button' value='$num'>Like</button>";
?>


(you shouldn't use a submit button for this purpose really..)
$('#like_button').click(function()
{
	// here i want to get the value of $num
        // $(this).val();	
});

This post has been edited by andrewsw: 23 December 2012 - 03:24 AM

Was This Post Helpful? 0
  • +
  • -

#17 SpAm101  Icon User is offline

  • D.I.C Head

Reputation: 11
  • View blog
  • Posts: 54
  • Joined: 28-November 12

Re: link open jquery function

Posted 23 December 2012 - 08:06 AM

Hi hwoarang69

PHP executes before the page code is returned to the client, so you can simply do this:

var variableName = <?php echo $num ?>

$('#like_button').click(function()
{
   alert(variableName);
		
});


This post has been edited by SpAm101: 23 December 2012 - 08:06 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2