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
    Regular Coder
    Join Date
    Jul 2005
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool not sure but editing and replacing text

    I have a DIV field set up, is it posssible to put text in there, then later on, retrive the DIV, add a couple lines on top of the code
    IE:


    old
    old
    old

    to

    new
    new
    old
    old
    old

    and, say if there is more then 10 lines, delete anything after that (guess itd check for <br>s ?)

    THanks if you know ..and post it :P

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    divobj.innerHTML='New String'+divobj.innerHTML;
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    Regular Coder
    Join Date
    Jul 2005
    Posts
    216
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by vwphillips
    divobj.innerHTML='New String'+divobj.innerHTML;
    i had that already..its the deleting part i dont have (making it so only say 10 lines show)

  • #4
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,518
    Thanks
    3
    Thanked 506 Times in 493 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    </head>
    
    <body>
    <div id="fred" >
    0<BR>
    1<BR>
    2<BR>
    3<BR>
    4<BR>
    5<BR>
    6<BR>
    7<BR>
    8<BR>
    9<BR>
    10<BR>
    11<BR>
    12<BR>
    13<BR>
    14<BR>
    15<BR>
    16<BR>
    17<BR>
    18<BR>
    19<BR>
    </div>
    
    
    <script language="JavaScript" type="text/javascript">
    <!--
    var obj=document.getElementById('fred');
    var string=obj.innerHTML.split('<BR>');
    string.length=10;
    obj.innerHTML=string.join('<BR>');
    //-->
    </script>
    
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/


  •  

    Posting Permissions

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