Im trying to get a database sorted out but I seem to be having a problem.
The following is the problem boiled down to a one page html document, the idea being that the document is able to re-write and display different forms for user selection as the user chooses different options..
The above works fine with only one <script>writeForm(2);</script> line in it, but add a second and you get:
Error:'top.List1Form.List1Item' is null or not an object.
If you remove the top.List1Form.List1Item.value=whichOption; line it all works fine so the problem seems to be the above line. I kinda get the feeling it's to do with trying to write a new form obejct which in effect already exists. Is this correct? If so how would I go about fixing this, do I have to kill off the form before or something? How do I do this? Am I trying to do this the wrong way?
Clarification would be appreciated, me confused
The following is the problem boiled down to a one page html document, the idea being that the document is able to re-write and display different forms for user selection as the user chooses different options..
<html>
<head>
<script>
function writeForm(whichOption)
{
top.document.open();
top.document.write("<body bgcolor=navy text=white>");
top.document.write("<form name='List1Form'>");
top.document.write("Main List :
");
top.document.write("<select name='List1Item'>");
top.document.write("<option value=1>a</option>");
top.document.write("<option value=2>b</option>");
top.document.write("</select></form>");
top.List1Form.List1Item.value=whichOption;
top.document.write("</body>");
top.document.close();
}
</script>
</head>
<body>
<script>writeForm(2);</script>
<script>writeForm(2);</script>
</body>
</html>
The above works fine with only one <script>writeForm(2);</script> line in it, but add a second and you get:
Error:'top.List1Form.List1Item' is null or not an object.
If you remove the top.List1Form.List1Item.value=whichOption; line it all works fine so the problem seems to be the above line. I kinda get the feeling it's to do with trying to write a new form obejct which in effect already exists. Is this correct? If so how would I go about fixing this, do I have to kill off the form before or something? How do I do this? Am I trying to do this the wrong way?
Clarification would be appreciated, me confused