Reputation: 3
I have an included page to the main index page, in the included page it has buttons to click on..i want to give these buttons a variable and when someone clicks on it, I can keep track of what button they selected in another page, which will show information for the selected button/variable...
Any ideas?
Upvotes: 0
Views: 130
Reputation: 245
Insert the jquery code to try out the click counts:
$(document).ready(function(){
var count =0;
$('button').click(function(){
count = count +1;
$('#showcount').html('click count' + count);
return false;
});
});
and somewhere in your body make a div with id = ' showcount' to show the click counts.
Or you can then save the click count into a text file to look at...or whatever
I hope this give you some ideas...
Upvotes: 0
Reputation: 19729
Well there is several ways to do this, but the main question is are you using a form button or a image button or a link or what?
Form:
HTML:
<form name="phpForm" action="myFile.php" method="get">
<input type="submit" name="button" value="1">
<input type="submit" name="button" value="2">
</form>
PHP:
<?PHP
echo $_GET["button"]; //either 1 or 2
?>
Image:
HTML:
<a href="myFile.php?button=1"><img src="whoo.png" /></a>
<a href="myFile.php?button=2"><img src="hilarious.png" /></a>
And the PHP above will also work with this.
Upvotes: 1
Reputation: 17169
There are several ways of doing this you can either use GET, POST, or store the variable in a SESSION
I am assuming when user clicks the button it is directed to another page, if its true, then you can do a GET with http://yoursite.com/pageTo.php?data='hello'
as the href that links to the button. Where pageTo.php would $_GET['data']
Upvotes: 0
Reputation: 786
Welcome to web programming, this should get you started: http://www.w3schools.com/php/php_intro.asp
Upvotes: 0
Reputation: 5240
You should really start reading a basic PHP tutorial.
Depending on what form is the method, you'll receive the variables in either $_POST
or $_GET
:
Use this code to find out
print_r($_GET);
print_r($_POST);
Upvotes: 0