Adding single quote to javascript/php block

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rich

    Adding single quote to javascript/php block

    I have a block of code that calls a function to copy some text to the
    clipboard. The text includes some text and an email from a recordset.
    I am trying to put the email address inside a single quote however
    any PHP or javascript methods that I try to use causes the function
    not to work. If I want to add a single quote should I put it inside
    the php echo or in between? and if so how should I format?


    <span onclick='return copy_clip("<?ph p echo 'The payers email is ';
    ?><?php echo $row_rsPayments['payer_email']; ?>")'>Click Here</span>
  • Stuart Palmer

    #2
    Re: Adding single quote to javascript/php block

    Rich,
    Here is the code you want your PHP to output:
    <span onclick="alert( 'The payers email is \'blah@blah.com \'');">Click
    Here</span>

    the \' cancels out the special meaning of the ' so just displays ' instead.

    Stu

    "Rich" <tdmailbox@yaho o.com> wrote in message
    news:22e731d7.0 402252155.49740 2aa@posting.goo gle.com...[color=blue]
    > I have a block of code that calls a function to copy some text to the
    > clipboard. The text includes some text and an email from a recordset.
    > I am trying to put the email address inside a single quote however
    > any PHP or javascript methods that I try to use causes the function
    > not to work. If I want to add a single quote should I put it inside
    > the php echo or in between? and if so how should I format?
    >
    >
    > <span onclick='return copy_clip("<?ph p echo 'The payers email is ';
    > ?><?php echo $row_rsPayments['payer_email']; ?>")'>Click Here</span>[/color]


    Comment

    Working...