You shouldn't have any problem doing the above. The one issue you need to be aware of is this. When you use the "inline DIV" option of the DHTML window to populate it, what the script does is copy the contents of the specified DIV into itself. This means any ID attributes inside this DIV will be duplicated, which semantically isn't allowed in HTML. I suspect this is your problem. You can overcome this by either:
1) Emptying the DIV once the DHTML window has grabbed its contents, so there are no longer 2 identical ID sets out there.
2) Use the "inline" option of DHTML window to directly pass in a string containing your FORM HTML into the DHTML window to be used as its contents.
Below shows how to do this using option 1):
Code:
<script type="text/javascript">
//Write out DIV to contain form
document.write('<div id="somediv" style="display:none"></div')
var formcontents='<form id="testform"><br /><input type="text" id="yourname" /><br /><input type="text" id="thoughts" /><br /><input type="submit" /></form>'
//Populate DIV with form
document.getElementById("somediv").innerHTML=formcontents
function opendhtmlwindow(){
divwin=dhtmlwindow.open('divbox', 'div', 'somediv', '#4: DIV Window Title', 'width=450px,height=300px,left=200px,top=150px,resize=1,scrolling=1')
document.getElementById("somediv").innerHTML=""
document.getElementById("yourname").focus()
document.getElementById("thoughts").value="How's it going?"
}
</script>
<p>Play around with Window 4 (Content from a DIV on page)</p>
<a href="#" onClick="opendhtmlwindow();return false"><b>Create/ Open Window 4</b></a>
The line in red empty's the orignal DIV's contents once the DHTML window has grabbed its contents. Once that's done, you can access the form as if it was on the page itself.
Bookmarks