I would like to know if my approach is efficient and correct. my code is not working though, I don\'t know why.
Several problems.
1) There is no need for the function to be within $(document).ready
, get rid of that.
2) Every case statement should be followed by a break
, not a lone ;
. For example:
function HotelQuery(HotelName) {
switch (HotelName) {
case 'TetrisHotel':
// stuff goes here ...
break; //end Tetris Hotel
};
}
3) alert
shouldn't be followed by a :
in your onclick
handler:
alert: (strHotelName, strHotelDesc, strHotelPrice);
should be
alert(strHotelName, strHotelDesc, strHotelPrice);
Also, alert
only takes one parameter, so you need to break it up:
alert(strHotelName); alert(strHotelDesc); alert(strHotelPrice);
3) You're assuming strHotelName
, strHotelDesc
and strHotelPrice
are in the global scope, which they are not.
Altogether, you might want to try something like this:
hotel query
Tetris Hotel Query