As far as the seats appearance, you'll need to use CSS to define a "container" of where you will store the seats themselves that has an explicit width, which you can see in the CSS my example provided :
<style type="text/css">
/* Defines your container width */
#SeatingSection { width: 150px; }
/* A generic class for each of your "seats" that specifies a size and will make them "float" */
.seat { float : left; height: 20px; width: 20px; background : #ddd; margin: 2px; color: #fff }
/* Coloring based on availability */
.seat.available { background: green; cursor: pointer; }
.seat.not-available { background: red; }
</style>
You could possibly use jQuery to add your "selectable" functionality so when an available seat was clicked on it would add a "selected" class to them and when your button was clicked, you could use the selected class to determine which seats were selected :
<script type='text/javascript'>
$(function(){
//When an available seat is clicked on
$('.seat.available').click(function(){
//Toggle selection for this seat
$(this).toggleClass('selected');
});
//When your "Purchase" button is clicked
$("#Purchase").click(function(){
//Grab the selected seats
var selected = $(".seat.selected");
if(selected.length == 0){
alert("No seats were selected.");
}
else{
alert(selected.length + ' seats were selected. Proceed to Purchase screen.');
//You may want to add some additional properties to store your seat ID within your
//seat <div> elements so that you can read them here (look into HTML5 data-attributes)
}
});
});
</script>
As far as actually mapping the values, you may want to create a numbering system that would output them in order (this part is a bit tricky) and may require you to sort them in a specific way to get them to output properly (especially if the
venue doesn't have a very rectangular seating arrangement).
All-Star
114593 Points
18503 Posts
MVP
Re: Display map of clickable buttons and highlight some based on a condiiton
Sep 30, 2013 08:43 AM|Rion Williams|LINK
As far as the seats appearance, you'll need to use CSS to define a "container" of where you will store the seats themselves that has an explicit width, which you can see in the CSS my example provided :
You could possibly use jQuery to add your "selectable" functionality so when an available seat was clicked on it would add a "selected" class to them and when your button was clicked, you could use the selected class to determine which seats were selected :
As far as actually mapping the values, you may want to create a numbering system that would output them in order (this part is a bit tricky) and may require you to sort them in a specific way to get them to output properly (especially if the venue doesn't have a very rectangular seating arrangement).
AjaxjQuery