SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using double quotation marks inside onClick()?

    How do I use double quotation marks in a string that should be inserted into a textarea or shown in a pop-up. Like if I want a link to be inserted:

    Code:
     
    <input type="button" value="Insert" class="button" onClick="newsinsert('<a href=" + document.form.altemail.value + ">Name</a>');">
    As you can see, the double quotation marks in the link is missing. How can I add them without JS ending the string?

  2. #2
    SitePoint Evangelist Mr. Brownstone's Avatar
    Join Date
    May 2002
    Location
    Relative
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Stick a back-slash in front:
    Code:
    '<a href=\"" + document.form.altemail.value + \"">Name</a>'
    Of course, that's just my opinion. I could be wrong.

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mr. Brownstoone, that doesn't work...
    However, I got an email that adios had replied and his example worked. For some reason his post isn't here though...Thanks anyway

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hah! Always nice to hear.

    Re-read your question, and decided I wasn't entirely sure what you were doing and didn't wan't to mislead you - so I deleted my response. This is the opposite of my usual procedure, where I wish I had deleted my response.
    ::: certified wild guess :::

  5. #5
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    407
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hehe, well
    Code:
    <input type="button" value="Insert" class="button" onClick="newsinsert('<a href=""&quot;' + 'test' + '&quot;>Name</a>');">
    did exactly what I wanted. Thanks for the help

  6. #6
    SitePoint Evangelist Mr. Brownstone's Avatar
    Join Date
    May 2002
    Location
    Relative
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LOL Sorry my post did not help; I did not test it beforehand.
    Of course, that's just my opinion. I could be wrong.


Bookmarks

Posting Permissions

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