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

The Archive Base Latest Questions

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

Is there any syntax error, cause it is not working currently? However, it is

  • 0

Is there any syntax error, cause it is not working currently? However, it is working if comments .click(check(seats[i])); and uncomment .click(deleteBooking); & .toggle(appendBooking, deleteBooking); .

Thanks in advance.
Cheers.

$(document).ready(function() {
function Seat(seat_xcoord, seat_ycoord, row_name, row_label, column_name, column_label){
this.seat_xcoord = seat_xcoord;
this.seat_ycoord = seat_ycoord;
this.row_name = row_name;
this.row_label = row_label;
this.column_name = column_name;
this.column_label = column_label;
this.state = false;

this.getState = function(){
return this.state;
}

this.setFstate = function(){
this.state = true;
}

this.setTstate = function(){
this.state = false;
}
}

function check(Seat){
if(Seat.getState==false){
appendBooking();
Seat.setTstate();
}else{
deleteBooking();
Seat.setFstate();
}
} 

var seats = new Array();    

var i =0;   
var price = 0;

$.get('seating_plan.xml', function(d){
$(d).find('seat').each(function(){
    var $seat = $(this);
    var seat_xcoord = $seat.attr("seat_xcoord");
    var seat_ycoord = $seat.attr("seat_ycoord");
    var row_name = $seat.attr("row_name");
    var row_label = $seat.attr("row_label");
    var column_name = $seat.attr("column_name");
    var column_label = $seat.attr("column_label");          
    var leftValue = seat_xcoord*20;
    var bottomValue = seat_ycoord*20;

    seats[i]= new Seat(seat_xcoord, seat_ycoord, row_name, row_label, column_name,   column_label);

    var $ticketRowDiv = $('<div id="ticket'+i+'"></div>'); //One row of ticket details
    var $ticketInfoDiv = $('<div class="ticket-item">'+row_name+column_name+'</div><div class="ticket-item">$15.50</div>');

    function deleteBooking(){
        $seatdiv.css("background-color","#42de18"); //change seat color back to green
        $ticketRowDiv.hide(); //hide the ticket details
        price = price-15.50; 
        $('#price h1').html('$'+price); //display total price
    }

    function appendBooking(){
        $seatdiv.css("background-color","#f64848"); //change seat color to red
        $('#details').append($ticketRowDiv); //add ticket details to sidebar
        $ticketRowDiv.show(); 
        price =price+15.50; 
        $('#price h1').html('$'+price);//display total price
        check(seats[i]);
    }

    function seatHover(){
        $(this).addClass("seat-hover");
    }

    function seatUnHover(){
        $(this).removeClass("seat-hover");
    }

    var $dltDiv = $('<div id="dlt_seat'+i+'" class="ticket-item"><a href="#">delete</a></div>')
                //.click(deleteBooking);
                .click(check(seats[i]));

    $ticketRowDiv.append($ticketInfoDiv); //append "seat No." and "sub Total" to a ticket details row
    $ticketRowDiv.append($dltDiv); //append "delete" link to a ticket details row

    var $seatdiv = $('<div id = "seat'+i+'" class="seat"></div>')
                .css({left: leftValue + 'px', bottom: bottomValue + 'px'})   //define seat location in seating map
                .hover(seatHover,seatUnHover)
                .click(check(seats[i]));
                //.toggle(appendBooking, deleteBooking); 

    $('#canvas').append($seatdiv); //add a seat to seating map
    i++;
});
}); 

});
  • 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-12T16:49:36+00:00Added an answer on June 12, 2026 at 4:49 pm

    You are binding the return value from the function check, not the function, ane the function doesn’t return anything.

    Bind an anonymous function that calls the check function:

    .click(function(){ check(seats[i]); });
    

    However, you need to create a closure around the code to capture the value of i instead of the variable itself, as the variable changes before the event happens:

    var $dltDiv = (function(i) {
      return $('<div id="dlt_seat'+i+'" class="ticket-item"><a href="#">delete</a></div>').click(function(){ check(seats[i]); });
    })(i);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there any resources on how do I use the not() syntax in a
Does the BlackBerry Java SDK support 1.5 syntax? If not, has there been any
Are there any wiki syntax like rdoc, markdown, ... recommended in the ruby world?
Is there any short syntax for if-else statement in objective C like PHP: if($value)
I use the rails 3.0.0.beta Is there any new syntax to write RJS, here
Is there any online utility to convert jquery syntax to mootools syntax? Is there
Are there any Drupal IDE's with syntax highlighting, and possibly intellisense, function descriptors?
Is there any tangible difference between the two forms of syntax available for creating
Is there any way I can get my Python code syntax highlighted in Microsoft
In OpenGL GLSL syntax, is there any difference between the components of a vector?

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.