Hi there!
I'm new in JavaScript - I have a few button that i want to change their background image when i click them.
What am I doing wrong? This is my code:
<script type="text/javascript">
function Seat_OnClick(control)
{
var selectedImg = "url(../images/selected_seat.jpg) no-repeat transparent";
var deselectImg = "url(../images/normal_seat.jpg) no-repeat transparent";
var handiImg = "url(../images/handicap_seat.jpg) no-repeat transparent";
if (control.style.backgroundImage == selectedImg)
control.style.backgroundImage = deselectImg;
else if (control.style.backgroundImage == deselectImg || control.style.backgroundImage == handiImg)
control.style.backgroundImage = selectedImg;
else if ((control.id == seat1_3 || control.id == seat1_4 || control.id == seat1_5) && control.style.backgroundImage == selectedImg)
control.style.backgroundImage = handiImg;
}
</script>
<button class="seat_button" id="seat1_1" onclick="Seat_OnClick(this)"></button>
The buttons are inside a table...