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

  • SEARCH
  • Home
  • 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 8603619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:22:00+00:00 2026-06-12T02:22:00+00:00

I thought I solved the issue in a preceding question but it is sill

  • 0

I thought I solved the issue in a preceding question but it is sill not working. I want to change the php variables ($start and $end called by var b1 and var b2) if the admin clicks on button. After this the new code should be availble for every visitor, so it should make a server request. Here is my updated code:

<?php
  if(date('w') == 4){ // day 2 = Tuesday

$start = strtotime('9:30');
$end = strtotime('12:30');
$timenow = date('U'); 
if ($timenow >= $start && $timenow <= $end) { 
 echo'<div id="iar_eu">';
echo quick_chat(200, 'default', 1, 'left', 0, 0, 1, 1, 1);
 echo'</div>';
 } } 
 ?>

</div>



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

  <script type="text/javascript">



if(jQuery('#start_chat').data('clicked')) {
   // change var b1 and b2
  $.ajax({
    type: "POST",
    url: "/web/htdocs/www.fattorefamiglia.com/home/wp-content/themes/child_care_creative/chat.php",
    dataType: 'json',
    data: { b1: "1:00", b2: "23:00" }
}).done(function(data) {
    b1 = data.b1;
    b2 = data.b2;
});}

else {
   $.ajax({
    type: "POST",
    url: "/web/htdocs/www.fattorefamiglia.com/home/wp-content/themes/child_care_creative/chat.php",
    dataType: 'json',
    data: { b1: "9:00", b2: "18:00" }
}).done(function(data) {
    b1 = data.b1;
    b2 = data.b2;
});}



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

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

});


</script>

chat.php:

<?php
// 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);

?>

Nothing happens when I click the button. What am I doing wrong?

  • 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-12T02:22:02+00:00Added an answer on June 12, 2026 at 2:22 am

    This line

    if(jQuery('#start_chat').data('clicked')) { 
    

    will never be true since .data('clicked') is not set until #start_chat is clicked which always will happen after the check has been made.

    You need to rethink your process of what you want to accomplish.

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

Sidebar

Related Questions

- Running PHP 5.3.8 on Linux- To start, we have solved this issue to
i thought i had solved this but my basic example seems to not be
On Monday, I thought I had solved the session hijacking security issue by setting
I thought this would be fairly simple but it turns out not to work
EDIT: This question is solved, but I can't accept my own answer just yet.
I'm sure this issue can be solved rapidly, but I don't find any answer
Carrying on from my previous question, which has now been solved: Issue with Pointers
Alrighty, I'm getting quite frustrated, namely because I thought I had this issue solved,
After asking my last question I thought the problem was solved, and the answer
I'm sure this issue can be solved rapidly, but I don't find any answer

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.