Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am creating a theater booking system. I am facing problems which selecting and saving the seats using a seat plan.


<!DOCTYPE html>
 
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<style>
.seat {
height: 20px;
width: 20px;
border: 1px solid gray;
cursor:pointer;
background-color:white;
}
.walk{
padding-left:20px;
}
#driver {
background-color:gray;
height: 20px;
border-radius: 50%;
}
 
</style>
 

 
</head>
<body>
 
<div style="border:1px solid gray; width:130px;">
<table>
<tr>
<td colspan="4"></td>
<td align="right"> <div id="driver"></div> </td>
</tr>
<tr>
<td><div class="seat"></div> </td>
<td><div class="seat"></div></td>
<td class="walk"> </td>
<td><div class="seat"></div></td>
<td><div class="seat"></div></td>
</tr>
<tr>
<td><div class="seat"></div> </td>
<td><div class="seat"></div></td>
<td class="walk"> </td>
<td><div class="seat"></div></td>
<td><div class="seat"></div></td>
</tr>
<tr>
<td><div class="seat"></div> </td>
<td><div class="seat"></div></td>
<td class="walk"> </td>
<td><div class="seat"></div></td>
<td><div class="seat"></div></td>
</tr>
<tr>
<td><div class="seat"></div> </td>
<td><div class="seat"></div></td>
<td class="walk"> </td>
<td><div class="seat"></div></td>
<td><div class="seat"></div></td>
</tr>
<tr>
<td><div class="seat"></div> </td>
<td><div class="seat"></div></td>
<td class="walk"> </td>
<td><div class="seat"></div></td>
<td><div class="seat"></div></td>
</tr>
<tr>
<td><div class="seat"></div> </td>
<td><div class="seat"></div></td>
<td class="walk"> </td>
<td><div class="seat"></div></td>
<td><div class="seat"></div></td>
</tr>
<tr>
<td><div class="seat"></div> </td>
<td><div class="seat"></div></td>
<td class="walk"> </td>
<td><div class="seat"></div></td>
<td><div class="seat"></div></td>
</tr>
<tr>
<td><div class="seat"></div> </td>
<td><div class="seat"></div></td>
<td class="walk"> </td>
<td><div class="seat"></div></td>
<td><div class="seat"></div></td>
</tr>
<tr>
<td><div class="seat"></div> </td>
<td><div class="seat"></div></td>
<td class="walk"> </td>
<td><div class="seat"></div></td>
<td><div class="seat"></div></td>
</tr>
</table>
</div>
 

<script>
 
allSeats = document.querySelectorAll('.seat');
for (var i = 0; i < allSeats.length; i++) {
var seat = allSeats[i];
seat.addEventListener('click', function () {
var bgclr = this.style.backgroundColor;
if(bgclr =='red')
this.style.backgroundColor = 'white'
else
this.style.backgroundColor = 'red'
debugger
}, false);
}
 
</script>
 

</body>
</html>

What I have tried:

I have tried to make div runat="server" . I got a reference to use hidden field but unable to use it. I am not able to understand how to capture the selected div values in real time and capture it in asp.net(vb). Once i get the values in string format or through a label, rest database i can easily do it.
I am using asp.net using vb.net
A quick response would be highly appreciated.
Thanks
Natasha
Posted
Comments
A_Griffin 12-Nov-17 9:00am    
But the divs don't have any values in them? But a simple this.innerHTML in the same (or different) listener will yield any value you put in them, and you can send that to a generic handler (.ashx) via an AJAX call for processing.
Natasha Singh Delhi 12-Nov-17 10:30am    
If i assign a value to that div like: div id="xyz" runat="server" then also how to proceed
A_Griffin 12-Nov-17 12:11pm    
I don't know why you would want to do that. It won't help you capture anything in real time. But it's not really clear what you're trying to do, I'm afraid.
Natasha Singh Delhi 12-Nov-17 12:33pm    
I am just trying to put the seat numbers in all the divs and capture it when anyone selects them....is there any simpler way to do this ??
A_Griffin 12-Nov-17 12:52pm    
OK, well put the seat numbers in - they're not in your code. How you do that is up to you. But then you can capture when people click on a cell, just as you have done, and at the same time as turning it red you can use something like var seatNo = this.innerHTML which will then = whatever number is in that cell. You can then use that in whatever way you want.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900