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 8613263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:49:59+00:00 2026-06-12T04:49:59+00:00

I have problem with JavaScript/jQuery. I’m trying to change variable’s value after dialog is

  • 0

I have problem with JavaScript/jQuery. I’m trying to change variable’s value after dialog is displayed and if checbox is checked, but this don’t work when I check value of it. What can I do instead or this code is wrong?

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>JS/jQuery</title>
  <link rel="stylesheet" type="text/css" href="style.css">
  <script type="text/javascript" src="jquery-1.8.2.min.js"></script>
  <script type="text/javascript" src="myjs.js"></script>
</head>
<body>
  <div class="back"></div>
  <div class="start">   
    <label for="chex">Is this checkbox checked?</label>
    <input type="checkbox" id="checkexist" name="chex" />
    <button id="run">Run form</button>
  </div>
  <div class="window"></div>
</body>
</html>

JavaScript:

$(document).ready(function() {

  var start = false;
  var check = false;

  if (start == false) {
    $("#checkexist").click(function(){
        if (this.checked) {
            check = true;
        }
    });
    $("#run").click(function(){
        start = true;
        $(".start").fadeOut('slow', function(){
            $(".start").css("display", "none");
        });
        $(".back").fadeOut('slow', function(){
            $(".back").css({'display' : 'none', 'opacity' : '0', 'filter' : 'alpha(opacity=0)'});
        });
    });
  } else {
    if (check == true) {
        $(".window").click(function(){
            $(".window").hide('fast');
        });
    } else {
        //do something
    }
  }
});
  • 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-12T04:50:01+00:00Added an answer on June 12, 2026 at 4:50 am

    ok, so lets try solving this bit by bit.

    your code runs inside $(document).ready(function() {});
    and as you were told by others, if (start == false) {} this part will never run: else{}, since when the page loads, start will be always set to false (var start = false;)
    next,

    $("#checkexist").click(function(){
            if (this.checked) {
                check = true;
            }
        });
    

    could be replace with: $('#checkexist').is('checked') which will return true or false based on the checkmark. true for checked, false for unchecked.

    now, assuming we know that, and we know you want to run this when the button is clicked:

    $('#run').on('click', function(){
        // close the start and back
        $(".start,.back").fadeOut('slow');
        if ($('#checkexist').is(':checked'))
        {
            // checkbox is checked, close the .window
            $(".window").hide('fast');
        }else{
            //checkbox was not checked, what to do?
        }
    });
    

    Had a small syntax error.
    it work fine now.
    You can see it work here : http://jsfiddle.net/fp7kV/8/

    sorry, missed the :

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

Sidebar

Related Questions

I have a little problem closing my dialog box in JavaScript/jQuery on mouse exit.
I have a very simple JavaScript/jquery code which won't just work correctly. The problem
I have this html code <html> <head> <title>JQuery Problem 2</title> <script type=text/javascript src=jquery-1.4.min.js></script> <script
I like javascript, but I have problem with learning it :) I mean, i
Brainstorming needed . I have a problem with Javascript libraries (jQuery, ExtJS etc.) that
I'm building a jquery mobile site and I'm have some problem with javascript.if the
I'm using javascript and jQuery. I have a problem that my web app has
I have an ASP.NET gridview I want to manipulate using JavaScript/JQuery. The problem I
I have a problem with the javascript amcharts, but the situation is likely to
I'm totally newbie in javascript/jQuery and i have a little problem :) I'm using

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.