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
    Nov 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    div and functions

    I'm a biginner, and I can't understand the following script:
    there are 1 line written on the screen from the script, then when the function orra is 'activated ' this line dissapears and the other 2 lines appears.

    I wanted to not dissapear the first line, and I want in this way (with a function + other lines from outside the function)
    What I'm missing ?( the browser is Explorer)

    <html>
    <body id='ez' >

    <SCRIPT LANGUAGE="JavaScript">
    var orak= new Array(16)
    for (i=0;i<11;i++)
    {
    orak[i]=i
    }

    function orra() {
    yy=0
    xx=0
    document.write('<div id="masik" style="position:absolute;top:'+yy+'px;left:'+xx+';px;height:10px;width:10px">'+orak[10]+'</div>')
    document.write('<div id="masik" style="position:absolute;top:50px;left50;px;height:10px;width:10px">'+orak[9]+'</div>')

    }
    document.write('<div id="masik" style="position:absolute;top:20px;left20;px;height:10px;width:10px">'+orak[8]+'</div>')
    setTimeout('orra()',1500);
    </script>
    </body>
    </html>

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    I confess I don't understand your code either

    What is the use of that array, as long as you use a number? Why givving a length to that array, as long as you build another number of elements?

    Anyway, document.write is not a dynamic method. And it's deprecated.

    What is in fact your final goal?
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Nov 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK,
    this was a program to place some numbers on the screen - on specific positions, but these numbers and their position is changing (every second),and I used a function with a timer to place the numbers on their actual positions
    this code is only a part from the source - without loops and other math formulas.

    the question is

    how can I use a function for outputting some things on specific positions( I used divs for that)

    then recall that function for many times, to output another things, and the previos outputs to not dissapear

    thanks

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    you may use dynamic methods:

    object.innerHTML='sometext'
    or DOM method
    object.firstChild.data='sometext'
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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