I have some errors with my code. Maybe someone could help me. I am getting this error:
SyntaxError: missing formal parameter
function col(10,10){
And this is my code:
<script type="text/javascript">
function col(<?=$result['seats_count']?>,<?=$result['booked']?>){
if((<?=$result['seats_count']?>><?=$result['booked']?>))$('.table.table-bordered.booking tbody tr').css("background-color","#f55");
};
</script>
A FormalParameterList is a comma-separated list of Indentifier tokens.
Identifiers can only begin with an IdentifierStart:
IdentifierStart ::
UnicodeLetter
$
_
\ UnicodeEscapeSequence
Identifiers cannot begin with a number, so 10
is not a valid formal parameter. In creating your col
function code, your PHP code must produce formal parameter names that each begin with a letter (or one of the other valid beginning characters, as above).
Defining a function and calling it are 2 separate acts:
// 1. Define a function
function col(seatsCount, booked) {
if(seatsCount /*some operator*/ booked) {
$('.table.table-bordered.booking tbody tr').css("background-color","#f55");
}
}
// 2. Call the function
col(<?=$result['seats_count']?>, <?=$result['booked']?>);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With