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 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how would i find HTML and add to it

    yes, what would use to find HTML and add to it
    i know how to find text, with this
    document.getElementsByTagName('TD')[2].innerHTML.match(/ text blah/i)

    but that only finds text with in coding, i need something that will search for a </textarea> and add scripting after the sepcific tag
    thank you

  • #2
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    - not sure exactly what you had in mind, but this might be useful:

    Code:
    <html><head>
    <title>-</title>
    <script type="text/JavaScript">
    
    function insertNode(){var btn, txt, elm;
    
    btn = document.getElementsByTagName("button")[0];
    
    elm = document.createElement("LABEL");
    
    txt = document.createTextNode("label text");
    
    document.body.insertBefore(elm, btn.nextSibling);
    
    elm.appendChild(txt);
    }
    </script></head>
    <body>
    <button onclick="insertNode()">test</button>
    </body>
    </html>
    hmm... ?

  • #3
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, actually, i just wanted to add like a table, and text with it for like announcements and important threads
    how would i do that?
    and the exact place it needs to find is this
    <textarea name="message" rows="12" cols="60" wrap="soft" ONCLICK="javascript:storeCaret(this);" ONKEYUP="javascript:storeCaret(this);" ONCHANGE="javascript:storeCaret(this);" tabindex="3"></textarea>

    and have it add a table and text after that </textarea>
    how would that be done?
    thanks for the reply

  • #4
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    how would that be done?
    Pretty much just as in the example above: use the index of your textarea (instead of a button), and insert a table (instead of a label)...
    hmm... ?

  • #5
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, i tried this, but it didn't work (keep in mind i have no clue what i'm doing)

    <script type="text/JavaScript">

    function insertNode(){var btn, txt, elm;

    btn = document.getElementsByTagName("textarea")[0];

    elm = document.createElement("blah blah");

    txt = document.createTextNode("label text");

    document.body.insertBefore(elm, btn.nextSibling);

    elm.appendChild(txt);
    }
    </script>

  • #6
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try this:

    Code:
    <html>
    <head>
    <title>-</title>
    <script>
    function insertNode(){var tgt, tbl, tbd, tr, td, txt;
    
    tgt = document.getElementsByTagName("button")[0];
    
    tbl = document.createElement("TABLE");
    tbd = document.createElement("TBODY");
    tr  = document.createElement("TR");
    td  = document.createElement("TD");
    txt = document.createTextNode("cell text");
    
    td.appendChild(txt);
    tr.appendChild(td);
    tbd.appendChild(tr);
    tbl.appendChild(tbd);
    
    document.body.insertBefore(tbl, tgt.nextSibling);
    }
    </script>
    </head>
    <body><button onclick="insertNode()">test</button>
    </body>
    </html>
    this tutorial might help, also...
    hmm... ?

  • #7
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that didn't really work either, sorry for all the trouble

    see, this is exactly what i'm trying to do
    have something find this exact HTML
    Code:
    <textarea name="message" rows="12" cols="60" wrap="soft" ONCLICK="javascript:storeCaret(this);" ONKEYUP="javascript:storeCaret(this);" ONCHANGE="javascript:storeCaret(this);" tabindex="3"></textarea>
    and what i want added after it is this
    Code:
    <table border="0" cellspacing="1" cellpadding="0" align="center" width="70%" class="bordercolor"><tr class="catbg"><td align="center"><font color="990000"><b>Important Messages</b></FONT></TD><tr class="windowbg"><td><center>todays announcements!</center></td></tr></table>
    now if you need more of an idea of the layout of the section i'm altering, this is what it looks like
    i want a table of the right hand side of the posting area on this board
    http://tester4.proboards22.com/index...ng&action=post

  • #8
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that didn't really work either...
    The example works just fine for me.

    Whether it is tailored specifically to your needs is something for you to work out.

    Just take it one step at a time: do some research, test some methods, and act upon your observations.
    hmm... ?


  •  

    Posting Permissions

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