Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts

    Question writing out Javascript in PHP

    Can someone please tell me what is wrong with this?

    Code:
    echo '<button onclick="gohere("viewpub.php?PubID='.$row['PubID'].'")" id="button" ....

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,921
    Thanks
    15
    Thanked 228 Times in 228 Posts
    Purely javascript syntax.

    PHP Code:
    echo '<button onclick="gohere("viewpub.php?PubID='.$row['PubID'].'")" id="button" ....

    Needs to be;

    echo '
    <button onclick="gohere(\'viewpub.php?PubID='.$row['PubID'].'\');" id="button" ....

    so that single quotes enclose what is in parenthesis

  • Users who have thanked DrDOS for this post:

    jarv (12-12-2010)

  • #3
    Banned
    Join Date
    Mar 2007
    Posts
    1,523
    Thanks
    116
    Thanked 0 Times in 0 Posts
    Excellent! thanks a lot! x


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •