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
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    PHP and my javascript requires ' Apostrophes

    My php code looks like this

    echo userform ('', '<input readonly type="text" name="listing_description_counter" size="5" maxlength="5" value="' . $conf['listing_description_size'] . '"> ' . $lang['Characters_Left'] . ' test ') ;

    Where the test is, I need to put in the following Javascript coding and since this coding has Apostrophes, it is giving me an error when it is run on my apache server. Disphelp is a function.

    <a href="javascriptpenJavaScriptFunction();" id="none" onmouseover="Disphelp(this,'moon',false)" onmouseout="Disphelp(this,'moon',true)">display on page</a>


    I figured I could reference an outside .js file, but then I would have to make about 20 different .js files and that would not be very efficient.

    Any Ideas?

    Thanks,
    Brad

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    just escape any single quotes.

    PHP Code:
    echo userform ('''<input readonly type="text" name="listing_description_counter" size="5" maxlength="5" value="' $conf['listing_description_size'] . '"> ' $lang['Characters_Left'] . ' <a href="javascriptpenJavaScriptFunction();" id="none" onmouseover="Disphelp(this,\'moon\',false)" onmouseout="Disphelp(this,\'moon\',true)">display on page</a> ') ; 

  • #3
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Excellent,

    Adding the \before the ' and everything worked great.

    Thanks,
    Brad


  •  

    Posting Permissions

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