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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:47:13+00:00 2026-06-07T09:47:13+00:00

I have a div elements with data-seat and data-row property: <div class=’selected’ data-seat=’1′ data-row=’1′></div>

  • 0

I have a div elements with data-seat and data-row property:

<div class='selected' data-seat='1' data-row='1'></div>
<div class='selected' data-seat='2' data-row='1'></div> 
<div class='selected' data-seat='3' data-row='1'></div> 
<div class='selected' data-seat='1' data-row='2'></div>
<div class='selected' data-seat='2' data-row='2'></div>

I want print friendly message for selected seats:

var  selectedPlaceTextFormated =''; 
$(".selected").each(function () {

        var selectedPlace = $(this);

        selectedPlaceTextFormated += "Row " + selectedPlace.attr("data-row") + " (seat " + selectedPlace.attr("data-seat") + ")\n";
    });
alert(selectedPlaceTextFormated);

This code works well and shows the following:

Row 1 (seat 1)
Row 1 (seat 2)
Row 1 (seat 3)
Row 2 (seat 1)
Row 2 (seat 2)

But, I want group seats by row, i.e I want the following:

Row 1(seats: 1,2,3)
Row 2(seats: 1,2)

also, order by row number. How can I do this?
Thanks. DEMO

  • 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-07T09:47:15+00:00Added an answer on June 7, 2026 at 9:47 am

    Here is the code

    var selectedPlaceTextFormated ='';
    var row_array = [];
    
    $(".selected").each(function () {
        var selectedPlace = $(this);
        if (!row_array[selectedPlace.attr("data-row")]){
          row_array[selectedPlace.attr("data-row")] = selectedPlace.attr("data-seat");
        }
        else row_array[selectedPlace.attr("data-row")] += ','+selectedPlace.attr("data-seat");
    });
    
    for (row in row_array){
        alert("Row "+ row +"(seat " + row_array[row] + ")\n" );
    }
    

    And here the link to the working fiddle: http://jsfiddle.net/3gVHg/

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

Sidebar

Related Questions

I have two DIV-elements, which are assigned an array called stack using data() .
Say I have 4 div elements with class .navlink , which, when clicked, use
I have a Jquery Mobile controlgroup with two buttons: <div data-role=controlgroup data-type=horizontal class=headerMenu iconposSwitcher>
I have a template like this: <script id=notesTemplate type=text/html> <li class=Note> <div class=NoteDate data-bind=style:
I have 5 div elements with attribute data-role=content I select all of them by
Hi I have a number of elements: <div data-stage-1=hello>Hello</div> <div data-stage-2=hello>Hello</div> <div data-stage-3=hello>Hello</div> Using
I have this HTML document: <div id=c> <div class=base> <div class=cb id=red data-color=Red> </div>
I have set the data to div element and append it to another div
I have the following function to remove a DOM element div, $('#emDiv').on(click, ':button[data-emp-del=true]', function
I have set a background on the data-role=page element like so <div data-role=page style=background:

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.