Richard Cornford wrote:
"Dom Leonard" ...
<snip>
... . I hadn't realised submitting <display:none> fields was
a problem with NS6.xx - Opera up to 7.11 at least seems to
have similar problems. ...
<snip>
I did not find this problem in Opera 7. The test page I posted (without
the onsubmit handler) seems to have no problem sending the display:none
fields (at least using a get request) in Opera 7.0b1, 7.02 or 7.11.
The problem encountered was not with Opera submission, which I've tested
works using a post request as well, but with the data sent.
To go into detail, "similar problems" was in reference to failures
observed with form reset and script enquiry. Under Opera form reset
doesn't appear to reset fields within display:none containers, and
script enquiry of their values may be incorrect. The difference between
failure to submit form data, and submitting data that need not reflect
actions taken by the user is what I called "similar". I appreciate that
independant confirmation of these kinds of failures is important and
list the test page below. Initially I found reset problems using class
name switching so have included that as an option.
In regards the hack of substituting "height:0px; overflow:hidden" for
"display:none", testing in conjuction with the above showed that
although successful under IE5.0, it does not work under IE6. The near
substitute of "height:1px; overflow:hidden; visibility:hidden" appears
to work as written, but I can only indicate that it is last resort kind
of code, and if needed, should be taken "as is" for further testing.
Regards,
Dom
=======
<html><head><title>Form test</title>
<style type="text/css">
..classNone {
display:none;
}
..classHeight {
height: 0px;
overflow: hidden;
}
</style>
<script type="text/javascript">
var lastMethod="";
function hide(method) {
var div;
if(lastMethod)
return; // already hidden;
div=document.getElementById("test");
switch(lastMethod=method) {
case "classNone":
case "classHeight":
div.className=method;
break;
case "none":
div.style.display="none";
break;
case "height":
div.style.height="1px";
div.style.overflow="hidden";
}
}
function show() {
var div=document.getElementById("test");
switch(lastMethod) {
case "classNone":
case "classHeight":
div.className=""; break;
case "none":
div.style.display="block"; break;
case "height":
div.style.height="auto";
div.style.overflow="visible";
}
lastMethod=""; // re-arm
}
function enquire() {
alert("check1 " + document.forms.testForm.check1.checked
+ ", text1 " + document.forms.testForm.text1.value);
}
</script></head><body>
<form name="testForm" action="test.html">
<div id="test">
<input type="checkbox" name="check1"> (check1)<br>
<input type="text" name="text1" size="40"> (text1)
</div>
<input type="reset" value="Reset">
<input type="submit" value="Submit">
<p>
Hide by<br>
<a href="#" onclick="hide('classNone');return false";>className
(none)</a>, or
<a href="#" onclick="hide('none');return false;">style
display:none</a>, or<br>
<a href="#" onclick="hide('classHeight');return false";>className
(height)</a>, or
<a href="#" onclick="hide('height');return false;">style
height:1px</a>; or<br>
<a href="#" onclick="show();return false">Show</a> or<br>
<a href="#" onclick="enquire();return false;">Enquire</a><br>
</p>
<p>
NS6.xx doesn't submit from inside display:none</p>
<p>
Opera 7.03, 7.11 fails to reset check box or text within display:none.
Script enquiry for check box values within display:none returns false.
</p>
<p>Whilst IE5 hides for "height:0px;", IE6 fails for same setting.
</p>
</form>
</body></html>