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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    document.getElementById for JS var string

    I need to set a JS string variable that can ignore carriage returns. I have a working example using a hidden form element:

    <form name='nodeinfo>

    <input type='hidden' name='myMetadata' value="$node.meta('myValues')">

    </form>

    <script>
    var myString = document.nodeinfo.myMetadata.value;
    </script>

    Problem is this is limited to 512 characters.

    This string is coming from an outside system and could be 1500 characters long. I was wondering how to place it in a hidden table and get the string from there.

    Any help appreciated, particularly sample code.

    -mike

  • #2
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    additional info:

    All I get from the following is [object]. How do I get the string Div #1?

    <SCRIPT>
    function fnGetId(){
    // Returns the first DIV element in the collection.
    var oVDiv=document.getElementById("oDiv1");
    alert(oVDiv);
    }
    </SCRIPT>
    <DIV ID="oDiv1">Div #1</DIV>
    <DIV ID="oDiv2">Div #2</DIV>
    <DIV ID="oDiv3">Div #3</DIV>
    <INPUT TYPE="button" VALUE="Get Names" onclick="fnGetId()">

    -Mike

  • #3
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    One solution

    The following seems to do what I want:

    <div style="visibility: hidden;"><table><tr><td id="oDiv1"><p>This is a text</p><p><strong><font size="-1">But here is another test</font></strong></p></td></tr></table></div>
    <SCRIPT>

    // Returns the first DIV element in the collection.
    var oVDiv=document.getElementById("oDiv1").innerHTML;
    alert(oVDiv);

    </SCRIPT>

    Resulting alert gives me:

    <p>This is a text</p><p><strong><font size="-1">But here is another test</font></strong></p>

    Is there a better way to accomplish this?

    -Mike

  • #4
    Regular Coder
    Join Date
    May 2005
    Posts
    100
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't think so, your last post did it.


  •  

    Posting Permissions

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