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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:30:04+00:00 2026-06-10T09:30:04+00:00

I’m new to jQuery (or all things javascript, really) but know my way around

  • 0

I’m new to jQuery (or all things javascript, really) but know my way around php and basic programming – sorry if my question sounds utterly stupid, trying my best to learn.

I’m using a seat selection jQuery script outlined on TechBrij

This is the part of the code that selects the seat (from a layout of airplane/bus seats)

$('.' + settings.seatCss).click(function () {
    if ($(this).hasClass(settings.selectedSeatCss)){
        alert('This seat is already reserved');
    } else{
        $(this).toggleClass(settings.selectingSeatCss);
    }
});
$('#btnShowNew').click(function () {
    var str = [], item;
    $.each($('#place li.' + settings.selectingSeatCss + ' a'), function (index, value) {
        item = $(this).attr('title');
        str.push(item);
    });
    alert(str.join(','));
})

The selected Seat(s) are shown in an alert window on a click of a button & I want exactly that value.

I now want to pass the selected seat number into $_GET (or just into a php variable which I can then use as a $_GET value and just continue with it in PHP). If I understand it right I somehow need to grab the variable “str”? How would I do that?

Also, is there a way to limit the script to only allow ONE selected seat at a time? Right now it will only give an alert if I click on an already booked seat, I can select as many seats as I like, toggle them selected/unselected and such. Just setting it up that click on a seat set to “selectingSeatCss” will result in an alert would also stop me from unselecting it I guess.

  • 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-10T09:30:06+00:00Added an answer on June 10, 2026 at 9:30 am

    The second part of your question probably deserves its own question, but as for the main question:

    If you are trying to pass the JavaScript variabble into a PHP script, you need to use ajax:

    var seats = str.join(',');
    var request = $.ajax({
        type: 'GET',
        url: '/the/script/url.php?seats=' + seats,
        success: function (response) {
             // do something with response
        }
    });
    

    You probably want to read more about jQuery’s $.ajax here:
    http://api.jquery.com/jQuery.ajax/

    Although, it really might make more sense to just do something with the seats value using JavaScript on the page, depending on what you are trying to do. If you want to save it to a database, you will probably want to send it to your PHP script.

    UPDATE

    To just put the value in a form, and submit the form, create a regular HTML form (you can put display: none in the css to hide it) and then:

    var seats = str.join(',');
    $('#formId input[name=seats]').val(seats).submit();
    

    In this example, the form might look like this:

    <form id="formId" action="/path/to/script.php" method="post">
        <input name="seats" type="text" value="" />
        <input type="submit" value="submit" />
    </form>
    

    Then the value will be available to the recieving script in $_POST['seats']

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I am reading a book about Javascript and jQuery and using one of the
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported

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.