Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8554829
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:58:23+00:00 2026-06-11T14:58:23+00:00

I want to change php variable ($start and $end called by var b1 and

  • 0

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]');
  } ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:58:24+00:00Added an answer on June 11, 2026 at 2:58 pm

    on your current code here, add:

    // change var b1 and b2
    $.ajax({
        type: "POST",
        url: "chat.php",
        data: { b1: "123", b2: "456" }
    });
    

    on chat.php:

    $start = $_POST['b1'];
    $end = $_POST['b2'];
    

    Update:

    if you need to load back the data here in javascript:

    on chat.php make these changes:

    // variables
    if (!empty($_POST)) {
        $data['b1'] = $_POST['b1'];
        $data['b2'] = $_POST['b2'];
    }
    
    // to not lose them
    $_SESSION['chat'] = $data;
    
    // to keep it compatible with your old code
    $start = $data['b1'];
    $end = $data['b2'];
    
    // send the JSON formatted output
    echo json_encode($data);
    

    on your client-side code:

    // change var b1 and b2
    $.ajax({
        type: "POST",
        url: "chat.php",
        dataType: 'json',
        data: { b1: "123", b2: "456" }
    }).done(function(data) {
        b1 = data.b1;
        b2 = data.b2;
    });
    

    I didn’t test that, but hope it works!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please note that I want the compartment number to change. <?php $compartment = 1;
I have a change password script in PHP and I want to do is
url : http://localhost/back-office/index.php/staff/shopping when i change the category on every onchange event i want
i want change the content of a UITableView when i change a button, how
I have a RadioButtnList. I want change body background color based on radio button
I want to change a number to a string like this: var i =
I want to change EditText visibility to hidden when a button click. I write
I have a jQuery callback function. In that function I want it to change
I have the below jquery function $(function(){ $(select#rooms).change(function(){ $.getJSON(/admin/select.php,{id: $(this).val(), ajax: 'true'}, function(j){ var
I am currently writing a program in php. I want to let the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.