Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Problems with form elements that are hidden with <div style="display:none">

Reply
Thread Tools

Problems with form elements that are hidden with <div style="display:none">

 
 
Dan R Brown
Guest
Posts: n/a
 
      07-31-2003
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to
break up this form into several "tabbed" sections, I break up the form using <div>
tags. Each <div style="display:none"> can be displayed by setting the style attribute
to "display:", or hidden with "display:none". This gives the illusion that the person
filling out the form is switching from page to page...without the overhead of extra
hits on the server, since the entire page is already loaded on the client. It also has
the added advantage of being able to switch from section to section without any data
loss.

I have some simple javascript that changes the style attrs on the div tags (an onclick
event on the "tabs"), and this works fine.

Once the user finishes the form, the click submit and in theory the entire form is
submitted. The problem is when using NS6.x browsers ( a requirement for this project
), any form field that resides in a hidden div tag (<div style="display:none">) is
treated as if it does not exist. This is not a problem with IE6+ and NS7.x+.

Any help would be great!
Thanks,
Dan
 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      08-01-2003
"Dan R Brown" <(E-Mail Removed)> wrote in message
news:bgb8s6$vdp$(E-Mail Removed)...
<snip>
>... , the click submit and in theory the entire form is
>submitted. The problem is when using NS6.x browsers
>( a requirement for this project ), any form field
>that resides in a hidden div tag
>(<div style="display:none">) is
>treated as if it does not exist.
>This is not a problem with IE6+ and NS7.x+.


I suppose that I could boot the machine I have with Netscape 6.2
installed, create a test page and find out for myself but...

Are you saying that the form elements contained within DIV elements that
have style attributes that assign a display:none; property are not
submitted with the form or that the DIVs that have their style
properties set to 'none' at the point of submitting the form are not
included (or both)?

If the problem is associated with the initial setting of the style
attributes in the HTML then you probably should not have been doing that
anyway [1]. It would be possible to have the XSLT create an onload
handling function that set the initial display state of the DIVs on the
page.

If the problem is with the state of the display properties when the form
is submitted then it should be possible to reveal all the DIVs on the
page when the submit button is presses.

[1] The reason for using JavaScript to set the initial display
properties is that you need JavaScript to be available in order to
reveal them again. If the CSS sets the initial display states then any
style="display:none;" elements will just never be available in the
absence of JavaScript on the client.

The extent to which that is important may depend on the exact wording of
your specification. You say that the specification requires support for
Netscape 6.x. If your spec actually states a requirement to support
"JavaScript enabled Netscape 6.x" (or Net 6 in its default
configuration, or something similar) then you will be able to make a
JavaScript dependent site and meet the specification. However, if the
specification only states a requirement to support Netscape 6.x (along
with any other browsers included) then it could be reasonably
interpreted as requiring support for Netscape 6.x in any and all of its
user configurable states. Those user configurable states of course
include the option of turning JavaScript off (and quite a lot else
besides).

My experience of specifications that state a range of required browser
support is that they are backed by a contract with a client. If the
contract specifies browsers (only) then it would not be unreasonable for
a client, on discovering that they have been presented with a JavaScript
dependent site, to come back and say, "You knew that the browser was
configurable when you agreed to support it, only supporting the browser
in *one* of its configurations is not acceptable, go back and fix it or
we won't be paying.". And if they did, I think that they would be able
to make a good case in court, if it came to that.

Richard.


 
Reply With Quote
 
 
 
 
Dan R Brown
Guest
Posts: n/a
 
      08-01-2003
Richard Cornford <(E-Mail Removed)> wrote:
> Path: nntp.TheWorld.com!newsfeed.mathworks.com!kibo.news .demon.net!news.demon.co.uk!demon!not-for-mail
> From: "Richard Cornford" <(E-Mail Removed)>
> Newsgroups: comp.lang.javascript
> Subject: Re: Problems with form elements that are hidden with <div style="display:none">
> Date: Fri, 1 Aug 2003 01:48:03 +0100
> Lines: 62
> Message-ID: <bgcdc5$fg9$1$(E-Mail Removed)>
> References: <bgb8s6$vdp$(E-Mail Removed)>
> NNTP-Posting-Host: litotes.demon.co.uk
> X-Trace: news.demon.co.uk 1059698886 15881 212.229.126.254 (1 Aug 2003 00:48:06 GMT)
> X-Complaints-To: http://www.velocityreviews.com/forums/(E-Mail Removed)
> NNTP-Posting-Date: Fri, 1 Aug 2003 00:48:06 +0000 (UTC)
> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
> X-Priority: 3
> X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
> X-MSMail-Priority: Normal
> Xref: nntp.TheWorld.com comp.lang.javascript:417338


> "Dan R Brown" <(E-Mail Removed)> wrote in message
> news:bgb8s6$vdp$(E-Mail Removed)...
> <snip>
>>... , the click submit and in theory the entire form is
>>submitted. The problem is when using NS6.x browsers
>>( a requirement for this project ), any form field
>>that resides in a hidden div tag
>>(<div style="display:none">) is
>>treated as if it does not exist.
>>This is not a problem with IE6+ and NS7.x+.


> I suppose that I could boot the machine I have with Netscape 6.2
> installed, create a test page and find out for myself but...


> Are you saying that the form elements contained within DIV elements that
> have style attributes that assign a display:none; property are not
> submitted with the form or that the DIVs that have their style
> properties set to 'none' at the point of submitting the form are not
> included (or both)?


> If the problem is associated with the initial setting of the style
> attributes in the HTML then you probably should not have been doing that
> anyway [1]. It would be possible to have the XSLT create an onload
> handling function that set the initial display state of the DIVs on the
> page.


> If the problem is with the state of the display properties when the form
> is submitted then it should be possible to reveal all the DIVs on the
> page when the submit button is presses.


> [1] The reason for using JavaScript to set the initial display
> properties is that you need JavaScript to be available in order to
> reveal them again. If the CSS sets the initial display states then any
> style="display:none;" elements will just never be available in the
> absence of JavaScript on the client.


> The extent to which that is important may depend on the exact wording of
> your specification. You say that the specification requires support for
> Netscape 6.x. If your spec actually states a requirement to support
> "JavaScript enabled Netscape 6.x" (or Net 6 in its default
> configuration, or something similar) then you will be able to make a
> JavaScript dependent site and meet the specification. However, if the
> specification only states a requirement to support Netscape 6.x (along
> with any other browsers included) then it could be reasonably
> interpreted as requiring support for Netscape 6.x in any and all of its
> user configurable states. Those user configurable states of course
> include the option of turning JavaScript off (and quite a lot else
> besides).


> My experience of specifications that state a range of required browser
> support is that they are backed by a contract with a client. If the
> contract specifies browsers (only) then it would not be unreasonable for
> a client, on discovering that they have been presented with a JavaScript
> dependent site, to come back and say, "You knew that the browser was
> configurable when you agreed to support it, only supporting the browser
> in *one* of its configurations is not acceptable, go back and fix it or
> we won't be paying.". And if they did, I think that they would be able
> to make a good case in court, if it came to that.


> Richard.


The reason for using the <div> tags is to hide, or show, sections of the form to the
user. Each <div> sections the form based on a top, or category, related to the
information. When the user first navigates to the page a "general" section is
displayed, while all other sections are hidden from view (the xslt sets the correct
styles in the <div> tags. If the user wishes to see another section (i.e. xyz
settings), they click on the "xyz settings" tab / button. There is javascript
associated with the page that will set the style of the the previously viewed section
to hidden, and then display the "xyz settings" section of the form. This all works
fine.

What does not work (using NS6.x) is that when the form is submitted, any form element
that is hidden from view within <div style=display:none> tags, do not get sent (post or
get...it doesn't matter). NS6.x treats those form elements as if they do not exist on
the page, when in fact they do.

The suggestion of exposing all of the <div> tags, prior to submit works, but it's a
major eyesore that is not accepatble in our product ( which is not a web site, but a
browser based user interface for configurations ).

As far as the specification goes, NS6.x is a requirement...and javascript must be
enabled. The problem is not with the spec...it's with how NS6.x handles a css element.

Thanks for your reply
Dan
 
Reply With Quote
 
Richard Cornford
Guest
Posts: n/a
 
      08-01-2003
"Dan R Brown" <(E-Mail Removed)> wrote in message
news:bge2ho$7n1$(E-Mail Removed)...
<snip>
> The reason for using the <div> tags is to hide, or show, sections
>of the form to the user. Each <div> sections the form ...

<snip>

You said all that the first time.

> The suggestion of exposing all of the <div> tags, prior to submit

works,
>but it's a major eyesore that is not accepatble in our product ( which

is
>not a web site, but a browser based user interface for

configurations ).
<snip>

If the DIVs must be display:block for the submission to include their
contents then you have not choice but make that setting. However, how
does visibility:hidden effect the submissions, and is there any
potential for setting z-index and stacking all of the DIVs under the one
that you want to show at the end?

Richard.


 
Reply With Quote
 
Lasse Reichstein Nielsen
Guest
Posts: n/a
 
      08-01-2003
(E-Mail Removed) (HikksNotAtHome) writes:

> In article <bge2ho$7n1$(E-Mail Removed)>, Dan R Brown <(E-Mail Removed)>
> writes:
>
> >What does not work (using NS6.x) is that when the form is submitted,
> >any form element that is hidden from view within <div style=display:none>
> >tags, do not get sent (post or get...it doesn't matter). NS6.x treats those
> >form elements as if they do not exist on the page, when in fact they do.

>
> To you and IE, they may exist but to NS, they don't.


Then NS6 is broken. The form elements exists structurally in the document.
How CSS makes them look should not be important.

Is this a problem in later versions as well? I don't have NS6
available to check the problem right now, but I can't see the problem
in Mozilla FB 0.6.

Setting either the form, or a div containing an input, to display:none
will still include the element in the submission. This code puts bar=foo
in the resulting address
---
<form action="" method="GET" id="foo">
<div style="display:none">
<input type="text" value="foo" name="bar">
</div>
<input type="submit">
</form>
---

/L
--
Lasse Reichstein Nielsen - (E-Mail Removed)
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
 
Reply With Quote
 
Dan R Brown
Guest
Posts: n/a
 
      08-01-2003
Lasse Reichstein Nielsen <(E-Mail Removed)> wrote:
> Path: nntp.TheWorld.com!newsfeed.mathworks.com!irazu.swi tch.ch!switch.ch!npeer.de.kpn-eurorings.net!newsfeed.vmunix.org!uio.no!newsfeed1 .uni2.dk!newsfeed101.telia.com!nf01.dk.telia.net!n ews104.dk.telia.net!not-for-mail
> Sender: Lasse R. Nielsen@SUZIE
> Newsgroups: comp.lang.javascript
> Subject: Re: Problems with form elements that are hidden with <div style="display:none">
> References: <bge2ho$7n1$(E-Mail Removed)> <(E-Mail Removed)>
> From: Lasse Reichstein Nielsen <(E-Mail Removed)>
> Date: 01 Aug 2003 19:09:47 +0200
> Message-ID: <(E-Mail Removed)>
> User-Agent: Gnus/5.0808 (Gnus v5.8. XEmacs/21.4 (Native Windows TTY Support (Windows))
> MIME-Version: 1.0
> Content-Type: text/plain; charset=us-ascii
> Lines: 36
> NNTP-Posting-Host: 62.107.37.120
> X-Trace: 1059757503 news.stofanet.dk 7798 62.107.37.120
> X-Complaints-To: Telia Stofa Abuse <(E-Mail Removed)>
> Xref: nntp.TheWorld.com comp.lang.javascript:417400


> (E-Mail Removed) (HikksNotAtHome) writes:


>> In article <bge2ho$7n1$(E-Mail Removed)>, Dan R Brown <(E-Mail Removed)>
>> writes:
>>
>> >What does not work (using NS6.x) is that when the form is submitted,
>> >any form element that is hidden from view within <div style=display:none>
>> >tags, do not get sent (post or get...it doesn't matter). NS6.x treats those
>> >form elements as if they do not exist on the page, when in fact they do.

>>
>> To you and IE, they may exist but to NS, they don't.


> Then NS6 is broken. The form elements exists structurally in the document.
> How CSS makes them look should not be important.


> Is this a problem in later versions as well? I don't have NS6
> available to check the problem right now, but I can't see the problem
> in Mozilla FB 0.6.


> Setting either the form, or a div containing an input, to display:none
> will still include the element in the submission. This code puts bar=foo
> in the resulting address
> ---
> <form action="" method="GET" id="foo">
> <div style="display:none">
> <input type="text" value="foo" name="bar">
> </div>
> <input type="submit">
> </form>
> ---


> /L
> --
> Lasse Reichstein Nielsen - (E-Mail Removed)
> Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
> 'Faith without judgement merely degrades the spirit divine.'


It work fine in NS7.x, and with Mozilla 1.2 and up ( haven't tried it with any earlier
versions ).

Thanks,
Dan
 
Reply With Quote
 
Dan R Brown
Guest
Posts: n/a
 
      08-01-2003
Richard Cornford <(E-Mail Removed)> wrote:
> Path: nntp.TheWorld.com!newsfeed.mathworks.com!btnet-peer0!btnet-feed5!btnet!news.btopenworld.com!not-for-mail
> From: "Richard Cornford" <(E-Mail Removed)>
> Newsgroups: comp.lang.javascript
> Subject: Re: Problems with form elements that are hidden with <div style="display:none">
> Date: Fri, 1 Aug 2003 16:28:06 +0000 (UTC)
> Organization: BT Openworld
> Lines: 26
> Message-ID: <bge4em$apd$(E-Mail Removed)>
> References: <bgb8s6$vdp$(E-Mail Removed)> <bgcdc5$fg9$1$(E-Mail Removed)> <bge2ho$7n1$(E-Mail Removed)>
> NNTP-Posting-Host: host81-130-28-15.in-addr.btopenworld.com
> X-Trace: sparta.btinternet.com 1059755286 11053 81.130.28.15 (1 Aug 2003 16:28:06 GMT)
> X-Complaints-To: (E-Mail Removed)
> NNTP-Posting-Date: Fri, 1 Aug 2003 16:28:06 +0000 (UTC)
> X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
> X-MSMail-Priority: Normal
> X-Priority: 3
> X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
> Xref: nntp.TheWorld.com comp.lang.javascript:417396


> "Dan R Brown" <(E-Mail Removed)> wrote in message
> news:bge2ho$7n1$(E-Mail Removed)...
> <snip>
>> The reason for using the <div> tags is to hide, or show, sections
>>of the form to the user. Each <div> sections the form ...

> <snip>


> You said all that the first time.


>> The suggestion of exposing all of the <div> tags, prior to submit

> works,
>>but it's a major eyesore that is not accepatble in our product ( which

> is
>>not a web site, but a browser based user interface for

> configurations ).
> <snip>


> If the DIVs must be display:block for the submission to include their
> contents then you have not choice but make that setting. However, how
> does visibility:hidden effect the submissions, and is there any
> potential for setting z-index and stacking all of the DIVs under the one
> that you want to show at the end?


> Richard.



I will try the visibility:hidden to see if that works. Using z order for stacking has
it's draw backs in that when the page loads in, you see the various layers stacking
(probably due to the size of the page and the number of layers).

Thanks,
Dan
 
Reply With Quote
 
Richard Cornford
Guest
Posts: n/a
 
      08-02-2003
"Lasse Reichstein Nielsen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
<snip>
>>To you and IE, they may exist but to NS, they don't.

>
>Then NS6 is broken. The form elements exists structurally in
>the document. How CSS makes them look should not be important.


Netscape 6 was based on a pre-release Mozilla 0.9 and is one of the
buggiest browsers ever released. Requiring support for Net 6 seems like
an arbitrary decision based on the version numbers rather than any
understanding of the browsers in question.

I have just been testing this problem on Net 6 and the display property
does not effect the DOM. The DIVs and contained Input elements are all
there, and the elements are all in the form.elements collection;
readable, writeable, with their disabled properties set to false and so
on. Nothing accessible to JavaScript that would suggest that they should
not be successful controls. Yet if they are within a display:none block
they are not submitted.

>Is this a problem in later versions as well? ...

<snip>

No, it has been fixed.

Richard.


 
Reply With Quote
 
Jim Ley
Guest
Posts: n/a
 
      08-02-2003
On Sat, 2 Aug 2003 15:59:59 +0100, "Richard Cornford"
<(E-Mail Removed)> wrote:

>"Jim Ley" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
><snip>
>>Or tell the browser to sort itself out, and only support
>>standards conforming one's... oh no, people only do that
>>when IE is at fault...

>
>My inclination is not to bother the user about whether their browser is
>adequate or not.


Indeed, I wasn't being entirely serious. I can't find anything in
Bugzilla on this, has the OP told them?

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

 
Reply With Quote
 
Dom Leonard
Guest
Posts: n/a
 
      08-03-2003
Jim Ley wrote:
I can't find anything in
> Bugzilla on this, has the OP told them?
>


There is no need. See current mozilla bug-100533, fixed bug-60893, fixed
bug-34297

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
newb: recurse over elements children and disable all form elements SteveKlett@gmail.com Javascript 4 09-20-2006 07:42 AM
Problems with <SELECT> and hidden elements!! Omar Javascript 6 04-19-2005 10:03 PM
Problems with <SELECT> and hidden elements!! Omar Java 1 04-19-2005 06:03 AM
Does form.disable work on hidden text form elements? Mark Hannon Javascript 3 09-02-2004 11:37 PM



Advertisments