SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: div content

  1. #1
    SitePoint Member
    Join Date
    Feb 2003
    Location
    the netherlands
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    div content

    I have something betweem div tags:
    Code:
    <div id=test>blablabla</div>
    now how do I put what's between the tags in a javascript variable ?

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by FrzDiablos
    I have something betweem div tags:
    Code:
     
    <div id=test>blablabla</div>
    now how do I put what's between the tags in a javascript variable ?
    Code:
    var myvar = document.getElementById['test'].innerHTML;
    alert(myvar);

  3. #3
    SitePoint Member
    Join Date
    Feb 2003
    Location
    the netherlands
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Andrew-J2000
    Code:
    var myvar = document.getElementById['test'].innerHTML;
    alert(myvar);
    I tried this:

    Code:
    <div id="test">fnjdsbvdhsbfuiew</div>
    
    <script>
    
    var myvar = document.getElementById['test'].innerHTML;
    alert(myvar);
    
    </script>
    it tells me it's not an object ?

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by FrzDiablos
    I tried this:

    Code:
     
    <div id="test">fnjdsbvdhsbfuiew</div> 
     
    <script> 
     
    var myvar = document.getElementById['test'].innerHTML; 
    alert(myvar); 
     
    </script>
    it tells me it's not an object ?

    sry

    Code:
    <div id="test">fnjdsbvdhsbfuiew</div>
    
    <script type="text/javascript">
      var myvar1 = document.all['test'].innerHTML;
      var myvar2 = document.getElementById('test').innerHTML;
      alert('var 1 = ' + myvar1 + '\n' + 'var 2 = ' + myvar2);
    </script>

  5. #5
    SitePoint Member
    Join Date
    Feb 2003
    Location
    the netherlands
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay, my div tags are editable, but whenever in "enter" it puts in a
    Code:
    <P>
    I want it to dynamicly change to a

    Code:
    <br>
    I tried stuff with replace, and onChange but no effect.

    so basicly I want alle the P tags between the div tags dynamicly changed to BR tags...

    thx in advance

  6. #6
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its supposed to be like that, push shift and enter and it will return one line instead of placing a paragraph tag. If you really want to capture the enter command let me know.

  7. #7
    SitePoint Member
    Join Date
    Feb 2003
    Location
    the netherlands
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Andrew-J2000
    Its supposed to be like that, push shift and enter and it will return one line instead of placing a paragraph tag. If you really want to capture the enter command let me know.
    I figured the shift-enter key, it would be easier if it uses enter like in all programs. Bin messing around, and still no luck. Have tried multiply event triggers (onkeyup, onkeypress, onkeydown)

    with the following function:

    Code:
    function changebr()
    {
    var htmlCode = document.getElementById('iView').innerHTML;
    var pb = new RegExp ('<P>', 'gi');
    var pe = new RegExp ('</P>', 'gi');
    var htmlCode = htmlCode.replace(pe, '<br>') ;
    var htmlCode = htmlCode.replace(pb, '') ;
    document.getElementById('iView').innerHTML = htmlCode; 
    }

  8. #8
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by FrzDiablos
    I figured the shift-enter key, it would be easier if it uses enter like in all programs. Bin messing around, and still no luck. Have tried multiply event triggers (onkeyup, onkeypress, onkeydown)

    with the following function:

    Code:
     
    function changebr() 
    { 
    var htmlCode = document.getElementById('iView').innerHTML; 
    var pb = new RegExp ('<P>', 'gi'); 
    var pe = new RegExp ('</P>', 'gi'); 
    var htmlCode = htmlCode.replace(pe, '<br>') ; 
    var htmlCode = htmlCode.replace(pb, '') ; 
    document.getElementById('iView').innerHTML = htmlCode; 
    }
    http://andrew-j.port5.com/test/keyCapture.html


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
  •