javascript: silly onclick problem sending text

Joined
12 Feb 2006
Posts
17,605
Location
Surrey
very silly problem i can't seem to find the solution to.

i have a function called by an onclick event which sends 3 variables, first a number, then text, then a number.

when sending the text firefox throws up an error saying that whatever the text is set to is not defined, so say i had, onClick='showAlert(12, hi there, 41)', the error message i get is "hi there is not defined".

so what am i doing wrong?
 
Change
onClick='showAlert(12, hi there, 41)'
to
onClick="showAlert(12,'hi there', 41);"

It's treating hi there as variables when not surrounded by quotes.
 
Last edited:
Back
Top Bottom