SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Aug 2010
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript loop - to get element value from iframe

    Hi,

    Can anyone help me?

    iframe name/id = "monitor_V2"
    elements name/id= time1 time2 time3 time4............ time100

    the thing is, this code is working if I'm going to get only the value of "time1":

    Code:
    var ccount = window.frames['monitor_V2'].document.
                       getElementById('time1').innerHTML ;
    
    document.writeln(ccount);

    but if I loop this to get the value of "time1 to time100":


    Code:
    for (i=1; i<=100 ; i++)
    {
    
    
    var ccount = window.frames['monitor_V2'].document.
                      getElementById('time' + i).innerHTML ;
    
    
    
    document.writeln(ccount);
    }


    If I use this code.. it doesn't loop. It only displays the value of time100

    can anyone help me??

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,861
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    document.writeln is overwriting the entire web page with the value of ccount the first time it is called - the script then no longer exists and neither do any of the other frames you are wanting to process.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •