Closed Bug 110301 Opened 24 years ago Closed 24 years ago

form elements are not submitted when their containing element is hidden using the <element>.style.display = 'none'

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows NT
defect
Not set
major

Tracking

()

VERIFIED DUPLICATE of bug 34279

People

(Reporter: cnn, Assigned: alexsavulov)

Details

I have pages in which I want to allow the user to temporarily toggle the display of certain elements, especially on form pages, to simulate a 'tabbed screen'. I toggle the elements' display by containing them in either div or table elements which the user can decide whether to hide or display. The display toggle is achieved by using the style.display property of the containing elements, div or table. When the form is submitted, the elements contained in a non-visible element are not submitted. Here's some example HTML: -------------------------------- example html start -------------------------- <HTML> <HEAD> </HEAD> <BODY> <% Dim var For Each var In Request.Form Response.Write "<HR>" & var & " : " & Request.Form(var) & "<HR>" Next %> <form method="post"> <TABLE WIDTH=75% BORDER=1 CELLSPACING=1 CELLPADDING=1 > <TR> <TH></TH> <TH onClick="toggle(1)" onMouseOver="this.style.cursor = 'pointer';">Toggle Row 1</TH> <TH onClick="toggle(2)" onMouseOver="this.style.cursor = 'pointer';">Toggle Row 2</TH> <TH onClick="toggle(3)" onMouseOver="this.style.cursor = 'pointer';">Toggle Row 3</TH> </TR> <TR id="r1"> <TD>1</TD> <TD><input type=text name="txt-1-1" value="1"></TD> <TD><input type=text name="txt-1-2" value="2"></TD> <TD><input type=text name="txt-1-3" value="3"></TD> </TR> <TR id="r2"> <TD>2</TD> <TD><input type=text name="txt-2-1" value="4"></TD> <TD><input type=text name="txt-2-2" value="5"></TD> <TD><input type=text name="txt-2-3" value="6"></TD> </TR> <TR id="r3"> <TD>3</TD> <TD><input type=text name="txt-3-1" value="7"></TD> <TD><input type=text name="txt-3-2" value="8"></TD> <TD><input type=text name="txt-3-3" value="9"></TD> </TR> <TR id="r4"> <TD>4</TD> <TD><input type=text name="txt-4-1" value="10"></TD> <TD><input type=text name="txt-4-2" value="11"></TD> <TD><input type=text name="txt-4-3" value="12"></TD> </TR> <TR> <TD colspan=4 align=center><input type=submit name="btnSave"></TD> </TR> </TABLE> </form> <SCRIPT LANGUAGE=javascript> function toggle(i) { var o = document.getElementById('r' + i); if (!o) return; o.style.display = (o.style.display == 'none') ? '' : 'none'; } function onSubmitShow() { var o = null; for (var i = 1; i < 4; i++) { o = document.getElementById('r' + i); o.style.display = ''; } } </SCRIPT> </BODY> </HTML> -------------------------------- example html END -------------------------- This was taken from an ASP page, but you can easily remove the asp code, and change the destination of the form submission. Load this page in Mozilla, and hide some of the rows by clicking on the header columns title 'Toggle Row <n>', then submit the form, and look at form data. Any of the elements being hidden, are not submitted. I think this is a bug, this works in IE without a hitch, I've used it quite extensively. Incidentally, I was reading the HTML 4.0 spec, and I found the following: http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.13.2 ----------------------------------------------- Hidden controls and controls that are not rendered because of style sheet settings may still be successful. For example: <FORM action="..." method="post"> <P> <INPUT type="password" style="display:none" name="invisible-password" value="mypassword"> </FORM> will still cause a value to be paired with the name "invisible-password" and submitted with the form. ------------------------------------------------ Best Regards, Nick
Status: UNCONFIRMED → RESOLVED
Closed: 24 years ago
Resolution: --- → DUPLICATE
You don't mention what build you're using. This was fixed after 0.9.5 wass released; if your build is newer than the last week or so, and this still occurs, then please reopen. *** This bug has been marked as a duplicate of 34279 ***
verifying
Status: RESOLVED → VERIFIED
Component: HTML: Form Submission → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.