+ Reply to Thread
Results 1 to 1 of 1

Thread: Dynamic div id

  1. #1
    torwald.lung67 is offline x10Hosting Member torwald.lung67 is an unknown quantity at this point
    Join Date
    Sep 2010
    Posts
    14

    Dynamic div id

    Hi.
    I have found my old script, review code and like to bring them back to live but...
    part of the code dynamicly creates meny DIV elements:
    for (i=0;i<100;i++){
    document.write('<div id="star">*</div>');
    }
    now access to any style property in old times looked like this (for example ie):
    i=1 // or any number from 0 to 99
    document.all.star[i].style......
    Today it works in "ie8" and "chrome" but i like to rewrite script useing getElementById metod. It is hard to use old fassion metod becouse of compatybility with all major browsers.
    So... any clues how to dynamicly give unique id to dynamicly created divs?


    ...............

    Ok problem solved (for: firefox 3.6.15, chrome 5.2.0, IE 8.0). if u need solution for similiar problem:
    for (i=0;i<10;i++){
    document.write('<div id="star'+i+'" style="width:10px;height:10px;background-color:red;">*</div>');
    }

    access to element:
    for (i=0;i<10;i++){
    document.getElementById("star"+i).innerHTML="any text";
    }
    Last edited by torwald.lung67; 03-12-2011 at 09:13 AM. Reason: problem solved

+ Reply to Thread

Similar Threads

  1. Dynamic images with PHP
    By marshian in forum Tutorials
    Replies: 24
    Last Post: 10-30-2008, 11:14 AM
  2. Dynamic Sig
    By DefecTalisman in forum Off Topic
    Replies: 20
    Last Post: 09-30-2007, 03:29 AM
  3. dynamic ip problems
    By chunsiang in forum Free Hosting
    Replies: 5
    Last Post: 09-22-2007, 09:34 PM
  4. [OFF] Dynamic Sig
    By Brandon in forum The Marketplace
    Replies: 0
    Last Post: 03-19-2006, 12:16 PM
  5. Dynamic Sig
    By Brandon in forum The Marketplace
    Replies: 11
    Last Post: 02-12-2006, 10:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers