Web Analytics Made Easy -
StatCounter Dynamic value from a form inside of iframe not changing - CodingForum

Announcement

Collapse
No announcement yet.

Dynamic value from a form inside of iframe not changing

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamic value from a form inside of iframe not changing

    Dear all,

    pageone.htm has an iframe with pagetwo.htm inside
    pagetwo has a form with a hidden field that has a dynamic value.
    I'm trying to get that value from pageone.htm using:
    Code:
    var myid = window.frames['myiframe'].document.forms['myform'].elements['page'].value;
    This is working, but I just get the value that the field had when I did:
    Code:
     setInterval('alert(GetValue())', 9000);
    for the first time. All the alerts after the first one have the same value even when myid is changing in pagetwo.htm (tested alerting it in there).

    Is it a problem of cache? how can I fix this??
    I thought that by using setInterval I would be checking for a fresh value every 9 seconds but what I get is the same old value every 9 seconds Please help!

    See the whole code below.
    Thanks a lot in advance!


    Code:
    ///// pageone.htm /////
     
    <script type="text/javascript">
    function GetValue() {
    var myid = window.frames['myiframe'].document.forms['myform'].elements['page'].value;
    return myid;
    } 
    </script>
     
      </head>
      <body>
     
    <iframe id='myiframe' name='myiframe' width='1024' height='650px'src='pagetwo.htm'></iframe>
     
    <script type='text/javascript' language='JavaScript'>
     setInterval('alert(GetValue())', 9000);
    </script>
     
     
     
    ///// pagetwo.htm /////
     
    <FORM NAME='myform' METHOD='LINK' ACTION='pageone.htm'>
    <input id='page' name='page' type='hidden' value='"+myid+"'/>
    </FORM>

  • #2
    The value of the hidden field is a dynamic variable that comes from a quite huge programing too big to post it in here, but as I said before, I used alert in pagetwo.htm to check if it changes and has another value (this value is always a numer) and it does, it is dynamic, it changes.

    Where it does not change is in pageone.htm
    In pageone.htm I always get the value that the field had when I check it for the first time..

    Any ideas?
    Thanks again!

    Comment


    • #3
      I forgot to say that I'm afraid I cannot use any server side language in pagetwo.htm... I can use just javascript, jquery or ajax.
      Thanks agai

      Comment

      Working...
      X