views:

28

answers:

1

Hi, I'm trying to modify the value of a hidden input in an iframe I have on my page. I'm using the following javascript function:

function get_to(){
    alert(document.getElementById('poza_get').value);
    window.frames['frame01'].document.forms['newad'].elements['poza_src2'].value=document.getElementById('poza_get').value;
    alert('ceva');
}

The first alert shows me that the value of 'poza_get' is good. But the second alert doesn't show up suggesting that the function stopped after the second instruction. Probably because the second instruction didn't execute properly. I'm testing this on Google Chrome and this is the only method that worked for accesing the iframe's elements. But now I can't assign the value I want to 'poza_src2'.Any suggestions?

+1  A: 

I've always debugged with Firefox/Firebug, and highly suggest it.

But if you can't or won't use Firebug, try breaking the problem down to see where the issue happens, as with:

function get_to(){
    var val = document.getElementById('poza_get').value;
    alert(val);
    var ele = window.frames['frame01'];
    alert("1: "+ele);
    ele = ele.document.forms['newad'];
    alert("2: "+ele);
    ele = ele.elements['poza_src2'];
    alert("3: "+ele);
    ele.value = val;
    alert('ceva');
}
Carter Galle