Results 1 to 10 of 10

Thread: Apostrophe Issue

  1. #1
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Apostrophe Issue

    Anybody can help mi on this, { ' } thing.
    It's will display an IE error box whenever I refreshes.
    Pls help !!


    <td class="RowGrey" height="19"><a href="#" onClick="displayOnForm(
    'dog&#39;s&#39;');"> - </a> </td>

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    onClick="displayOnForm(
    'dog's'');"

    That's likely the issue.
    You should escape the single quotes you want displayed--
    'dog\'s'

    (What's the second single quote doing at the end of that?)
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    sorry to bother again.
    The contents within displayOnForm() is generated during runtime.
    So how can I change from { 'dog's'', } --> { 'dog\'s\'', } by using the function changeApostrophe()??
    Example like for the attribute = lastName

    Thanks once again.



    function changeApostrophe(text){
    var newString = "";
    for (var i = 0; text.indexOf("'") >= 0; i++) {
    var index = text.indexOf("'");
    var firstHalf = text.substring(0, index);
    newString = newString + firstHalf + "&#39;";
    text = text.substring(firstHalf.length + 1, text.length);
    }
    newString += text;
    return newString;
    }


    <td class="<cc:altColor/>" height="19"><a href="#" onClick="displayOnForm(
    '<cc:corpItemAttribute attribute='rowNo'/>','<cc:corpItemAttribute attribute='salutationId'> - <cc:staticModelItemAttribute modelalias='cc.salutation'/></cc:corpItemAttribute>',
    '<cc:corpItemAttribute attribute='industryId'> - <cc:staticModelItemAttribute modelalias='cc.industry'/></cc:corpItemAttribute>',
    '<cc:corpItemAttribute attribute='lastName'/>',
    '<cc:corpItemAttribute attribute='personnelId'> - <cc:staticModelItemAttribute modelalias='cc.personnel'/></cc:corpItemAttribute>',
    '<cc:corpItemAttribute attribute='firstName'/>','<cc:corpItemAttribute attribute='middleName'/>',
    '<cc:corpItemAttribute attribute='officeNo'/>','<cc:corpItemAttribute attribute='faxNo'/>',
    '<cc:corpItemAttribute attribute='mobtelNo'/>','<cc:corpItemAttribute attribute='email'/>',
    '<cc:corpItemAttribute attribute='homeNo'/>',
    '<cc:corpItemAttribute attribute='createUserId'> - <cc:staticModelItemAttribute modelalias='cc.userid'/></cc:corpItemAttribute>',
    '<cc:corpItemAttribute attribute='createDateTime'/>');">
    <cc:corpItemAttribute attribute='firstName'/></a>
    </td>

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    str = str.replace(/'/g, "\\'");
    I don't think this is what you're looking for, though. I think you want to be able to pass in an apostrophe-delimited string value containing apostrophes, then convert it. You can't do this, since as soon as it's seen it'll throw a parse error.

    What's this <cc:> namespace? I'm pretty sure that's not valid HTML. Is it parsed by the Javascript?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I using a jsp instead of a html. and the cc is a modified tag name. Nothing special about it.

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Ah, very well, so it'll be parsed into HTML by a server-side script.

    Well, so long as the output doesn't contain any apostrophes, you should be fine. If it does, you'll have to replace them server-side.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    No good, I'm only allow to code on the presentation tier not the business 1.
    Below is the output from the server, still got the "Expected )" error from IE.
    Oh God!!!!


    <td class="RowGrey" height="19"><a href="#" onClick="displayOnForm(
    '9',' - ',
    ' - ',
    'dog&#39;s&#39;',
    'P2 - PERSONNEL 2',
    'dog&#39;s&#39;','dog&#39;s',
    '123','',
    '123','13@dfg.edfg',
    '',
    'junyong - Lee Jun Yong',
    '11/07/2006 02:30:58 PM');">
    - </a>
    </td>

    <td class="RowGrey" height="19"><a href="#" onClick="displayOnForm(
    '9',' - ',
    ' - ',
    'dog&#39;s&#39;',
    'P2 - PERSONNEL 2',
    'dog&#39;s&#39;','dog&#39;s',
    '123','',
    '123','13@dfg.edfg',
    '',
    'junyong - Lee Jun Yong',
    '11/07/2006 02:30:58 PM');">
    dog&#39;s&#39;</a>
    </td>

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    There are still apostrophes there. There's one alternative left, but it's quite ugly:
    Code:
    <td class="<cc:altColor/>" height="19"><a href="#" onClick="displayOnForm(
    &quot;<cc:corpItemAttribute attribute='rowNo'/>&quot;,&quot;<cc:corpItemAttribute attribute='salutationId'> - <cc:staticModelItemAttribute modelalias='cc.salutation'/></cc:corpItemAttribute>&quot;,
    &quot;<cc:corpItemAttribute attribute='industryId'> - <cc:staticModelItemAttribute modelalias='cc.industry'/></cc:corpItemAttribute>&quot;,
    &quot;<cc:corpItemAttribute attribute='lastName'/>&quot;,
    &quot;<cc:corpItemAttribute attribute='personnelId'> - <cc:staticModelItemAttribute modelalias='cc.personnel'/></cc:corpItemAttribute>&quot;,
    &quot;<cc:corpItemAttribute attribute='firstName'/>&quot;,&quot;<cc:corpItemAttribute attribute='middleName'/>&quot;,
    '<cc:corpItemAttribute attribute='officeNo'/>&quot;,&quot;<cc:corpItemAttribute attribute='faxNo'/>&quot;,
    &quot;<cc:corpItemAttribute attribute='mobtelNo'/>&quot;,&quot;<cc:corpItemAttribute attribute='email'/>&quot;,
    &quot;<cc:corpItemAttribute attribute='homeNo'/>&quot;,
    &quot;<cc:corpItemAttribute attribute='createUserId'> - <cc:staticModelItemAttribute modelalias='cc.userid'/></cc:corpItemAttribute>&quot;,
    &quot;<cc:corpItemAttribute attribute='createDateTime'/>&quot;);">
    <cc:corpItemAttribute attribute='firstName'/></a>
    </td>
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to counter this kind of situation: when Quote meets Apostrophe

    I encounter javascript error when the a single input contains both quote and apostrophe. I tried to escape it using \" and &.#.3.9;for apostrophe &.q.u.o.t.;for quote. But no luck!!!





    <input type='hidden' name='rowNoItemAttr' value=\"2 \">
    <input type='hidden' name='salutationIdItemAttr' value=\"6 - ARCH"S \">
    <input type='hidden' name='industryIdItemAttr' value=\" - "\>
    <input type='hidden' name='lastNameItemAttr' value=\"Las't Name&quot; \">
    <input type='hidden' name='personnelIdItemAttr' value=\"P2 - PERSONNEL 2 \">
    <input type='hidden' name='firstNameItemAttr' value=\"Firs't Nam&quot;e \">
    <input type='hidden' name='middleNameItemAttr' value=\"Mi'ddle Nam&quot;e \">
    <input type='hidden' name='officeNoItemAttr' value=\"2123 \">

  10. #10
    Join Date
    Nov 2006
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    sorry guys, my mistake. I found the answer to my question.

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
  •