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


No announcement yet.

Dynamic value from a form inside of iframe not changing

  • 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:
    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:
     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!

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

  • #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!


    • #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