Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SyntaxError: missing formal parameter

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>
like image 284
user3852422 Avatar asked Sep 15 '25 21:09

user3852422


2 Answers

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).

like image 187
apsillers Avatar answered Sep 17 '25 11:09

apsillers


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']?>);
like image 38
tcooc Avatar answered Sep 17 '25 13:09

tcooc