Uncaught SyntaxError: Unexpected token ,

Can anyone tell me why this is causing an Uncaught SyntaxError: Unexpected token , error

I use this kind of function all the time but with numbers only - of course it relates to text but I just can not work out the correct " or ' to get this information to pass to my js function.

<a class="btn btn-primary btn-lg hidden-print" onclick="recordTB(52584,1,'Preliminary 7 2002',12/11/2017)" role="button"> Print &amp; Record</a>

Open in new window

Thank you
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

roblickleyAuthor Commented:
I should say that I have also tried it without any "  or ' and it equally doesn't work.
The text as is works perfectly for me.
Just created a random function with that signature, but no issues.

Can you post the JS function?
And you're getting this error in the browser (which one) or the IDE?
Also note, you should wrap the date at the end in quotes as well, otherwise the browser will just divide the numbers.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Julian HansenCommented:
I am guessing this
<a class="btn btn-primary btn-lg hidden-print" onclick="recordTB(52584,1,'Preliminary 7 2002','12/11/2017')" role="button"> Print &amp; Record</a>

Open in new window

i.e. enclose the date in single quotes.
As I suggested directly above ;)

But that still should not be the cause of the problem, as it's a perfectly valid mathematical expression (though obviously not what he's after), and all the commas flagging the token error come before that.
Julian HansenCommented:
@Snarf0001 - so you did - looked for a code block and did not find one so threw my 10c in.

I am guessing the syntax error is actually referring to something else - not that line. Maybe in the function itself.

Can we see a link?

Or at least more of the code?
Or similarly, if this happens to be rendered out with server code (the one you provided just being a sample), and you're writing out a full date in a different format, then the missing quotes IS quite likely the problem.

As you could end up with "Jan 1, 2012" for example.

As per Julian, we need a bigger picture.
roblickleyAuthor Commented:
Thank you all!
I wrapped the date in ' and it worked.
I did this before but it didn't work  - no idea why but it does not.
onclick="recordTB(52556,'YLHZDFK','Preliminary 1 2006','12/11/2017')"
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.