PDA

View Full Version : HELP!!! Problem with Mozilla and accessing form elements


Tommi
03-13-2003, 05:46 PM
Okay, I'm trying to write a function which has to access form elements of a document within an iframe for Mozilla 1.2.1

Here is the simplified code sample:


<script languag="JavaScript">

function x()
{
document.getElementById('i_anotherdocument').document.forms[0].anotherdocuments_inputline.value = 'whatever'; // does not work

frames['i_anotherdocument'].document.forms[0].anotherdocuments_inputline.value = 'whatever'; // does not work, either
}

</script>

<body>

<div id="anotherdocument">
<iframe id="i_anotherdocument" name="i_anotherdocument" src="anotherdocument.html"></iframe>
</div>

</body>



I hope you have a clue. The IE version works fine and now I'm trying to make it compatible with Mozilla.

ahosang
03-13-2003, 08:15 PM
Try:
document.getElementById('i_anotherdocument').contentDocument.forms[0].anotherdocuments_inputline.value = 'whatever'

Tommi
03-13-2003, 08:41 PM
Thanks fro your reply, I'm going to try that!