change php variable on click event

Posted by Claudiu on Stack Overflow See other posts from Stack Overflow or by Claudiu
Published on 2012-09-20T08:57:29Z Indexed on 2012/09/20 9:37 UTC
Read the original article Hit count: 175

Filed under:
|
|
|

I want to change php variable ($start and $end called by var b1 and var b2) if the user clicks on button. Now I know that php is server side, but how can I do it? I read something about using $get but I don't know how to implement it:

<?php if ( is_user_logged_in() ) { ?>
<input type="submit" value="Start Chat" id="start_chat" style="position: absolute; top: 30px; left: 10px;" />
<?php
 } ?> 

 <script>
jQuery('#start_chat').click(function(){
  $(this).data('clicked', true);
});

var b1 = '<?php echo $start; ?>';
var b2 = '<?php echo $end; ?>';


if(jQuery('#start_chat').data('clicked')) {
   // change var b1 and b2
} else {
    // do not change anything
}


</script>

<div id="eu_la">
<?php
$start = strtotime('9:30');
$end = strtotime('12:30');
$timenow = date('U'); 
if((date('w') == 4) && ($timenow >= $start && $timenow <= $end)) { // day 2 = Tuesday
  include('facut_mine.php');
   } 
  else {
do_shortcode('[upzslider usingphp=true]');
  } ?>

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript