All front-end programming only please.
Here is the actual site I am currently working on: http://alvincaseria.me/SJA100/ I have buttons which displays like this way:
- [stories before 1991] [ after 1991 ] [student before 1991]
- [stories for batch 1991] [ 1991 ] [ batch 1991]
- [stories after 1991] [ after 1991] [student after 1991]
What I'm trying to achieve is a php page that has a session variables that saves the year (example: 1991). Then as certain buttons are click, the variable changes it's value.
Example:
- When I click on the button [after 1991], the session runs a function that is suppose to increment the session variable named "batch"
- When I click on the button [before 1991], the session runs a function that is suppose to decrement the same variable.
Currently I am running a "Onclick=location.href..." but i want something like calling functions() as mentioned in this reference. How to Call a PHP Function on the Click of a Button
I am pretty new to php and ajax and I do not know how to call the mentioned reference to fit my current code since it is outside my page. If possible, can I do it without ajax?
Here is my Current Code, you can also check my current page as mentioned above.
<?php session_start(); // store session data $_SESSION['batch']=1991; ?> <html lang="en"> <head> ... </head> <body> <?php if($_GET['button1']){add1();} if($_GET['button2']){min1();} function add1() { $_SESSION['batch']=$_SESSION['batch']+1; } function min1() { $_SESSION['batch']=$_SESSION['batch']-1; } ?> ... more codes // After Year Chosen <div class="child"><button type="button" class="btn-styleBT">Short Stories of (Year chosen plus 1)</button></div> <div class="child"><button type="button" class="btn-styleCT" id="btn1" name="btn1" onClick='location.href="?button1=1"'> <?php //retrieve session data echo "after ".$_SESSION['batch']; ?> </button></div> <div class="child"><button type="button" class="btn-styleBT">Batch of (Year chosen plus 1)</button></div> ... more codes Middle divs <div class="child"><button type="button" class="btn-styleBT">Short Stories of (Year chosen minus 1)</button></div> <div class="child"><button type="button" class="btn-styleCT" id="btn2" name="btn2" onClick='location.href="?button2=1"'> <?php //retrieve session data echo "before ".$_SESSION['batch']; ?> </button></div> <div class="child"><button type="button" class="btn-styleBT">Batch of (Year chosen minus 1) </button></div> ... more codes Any ideas or suggestions?