-1

I need help with inserting php inside html. I have the below which causes me a javascript error.

The error being: Uncaught SyntaxError: missing ) after argument list. Can anyone help? Thanks

<a href="javascript:fin(<?php echo $character['addresses'][$i]; ?>) style="width:100%; height:100%;">

4
  • Strings in javascript need to be quoted, ie "some string", if your $character['addresses'][$i] is a string you didn't quote it Commented Nov 17, 2018 at 0:01
  • 2
    The href= is missing the terminating double-quote character. Commented Nov 17, 2018 at 0:02
  • If I quote the string I get a parse error. Commented Nov 17, 2018 at 0:07
  • Show the rendered output that will give you more clues on what is going on. You have to do both corrections, use the end quote for the href="..." and quote the php output Commented Nov 17, 2018 at 0:17

2 Answers 2

-1

You aren't closing your href property. Just add the closing double-quotes after your javascript parentheses. See the code below:

<a href="javascript:fin(<?php echo $character['addresses'][$i]; ?>)" style="width:100%; height:100%;">
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your help however closing the tag makes no difference, exactly the same error.
-1

Very strange, but an error within my javascript function cause the issue. I made a typo on a window.close call, I had put window..close by mistake.

Not sure why this would cause this error however I am also assuming that not closing the a href tag correctly would have caused a further error after correcting my double ..

Thanks for your help guys.

1 Comment

Problems caused by typos are off-topic because they are unlikely to help future visitors. You can delete this answer and then delete the question, to save it spending time in the review queues.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.