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
    Sep 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    .html() garbles div information

    It appears that .html() is somehow messing up reading the contents of a div.

    Here is my php code which loads into the div.

    Code:
    $own_pre_selection .= "<input name='" . mysql_result($result,$i,"did") . "' value='" . mysql_result($result,$i,"did") . "' type='hidden'><span class='addremove' onclick=\"recordchecks('" . mysql_result($result,$i,"dname") . "','" . mysql_result($result,$i,"did") . "')\";><u>Remove</u></span> &nbsp;" . mysql_result($result,$i,"dname") . "<br>";
    Here is what I see as source code after the page renders.

    Code:
    <input name='677' value='677' type='hidden'><span class='addremove' onclick="recordchecks('Heart Neoplasms','677')";><u>Remove</u></span> &nbsp;Heart Neoplasms<br><input name='1298' value='1298' type='hidden'><span class='addremove' onclick="recordchecks('Heart Septal Defects; Atrial','1298')";><u>Remove</u></span> &nbsp;Heart Septal Defects; Atrial<br></div>
    When I test alert() the .html() contents it appears like this. It seems to screw up the quote escape and changes \" to " ;="" after the recordchecks().

    Code:
    <input name="677" value="677" type="hidden"><span class="addremove" onclick="recordchecks('Heart Neoplasms','677')" ;=""><u>Remove</u></span> &nbsp;Heart Neoplasms<br><input name="1298" value="1298" type="hidden"><span class="addremove" onclick="recordchecks('Heart Septal Defects; Atrial','1298')" ;=""><u>Remove</u></span> &nbsp;Heart Septal Defects; Atrial<br>
    So even though the source code looks perfect, if I alert() the div contents with html() it seems to get a bit garbled in the process. Any ideas?

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,947
    Thanks
    79
    Thanked 4,424 Times in 4,389 Posts
    But this is bogus:
    Code:
    onclick="recordchecks('Heart Neoplasms','677')";>
    The semicolon should either not be there, at all, or should be *INSIDE* the "...".
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Sep 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ahhhh haha, thanks


  •  

    Posting Permissions

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