View Full Version : passing parameters to a function

03-21-2004, 06:33 PM
I am trying to pass a parameter to a function using 'onclick()'.

when I try onclick="resetColors(p_01)", i get an error message saying 'p_01 is not defined'.

when I try onclick="resetColors('p_01')", i get an error message saying 'syntax error'.

I am trying to send the parameter as the page number I am calling the resetColors() function from.

Please help. I have looked at several examples in the forum but still can't figure it out. Nothing I have tried so far works.

Thank you.

03-21-2004, 07:15 PM
onclick should be a function, that in turn calls the function you want with the parameters you want.
}As for the page number, how are you storing it?

03-21-2004, 07:19 PM
That is my problem. How do I store it or define it so I can pass it as a parameter?


03-21-2004, 07:28 PM
Any way you want. Either you send it as a literal which you enter as an argument to the function, or you store it in a variable which you send to the function.

03-21-2004, 08:03 PM
I can't believe how stupid I can be sometimes. I was watching TV and took my mind off the problem and suddenly the answer just popped into my head. Guess I need to take a break more often. Been at this project for about 30 hours straight now.

Thanks for all the help.