使用< div style =" display:none">隐藏的表单元素的问题 [英] Problems with form elements that are hidden with <div style="display:none">

查看:71
本文介绍了使用< div style =" display:none">隐藏的表单元素的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用xml / xslt在jsp中动态生成的大表单。因此,

将此表单拆分为几个tabbed表单。部分,我使用< div>

标记分解表单。每个< div style =" display:none">可以通过将样式属性

设置为display:来显示,或者使用" display:none"隐藏。这给人一种错觉,就是填写表单的人正在从一个页面切换到另一个页面......没有额外的开销,因为整个页面都会在服务器上点击b / b
已经加载到客户端上。它还具有

的额外优势,能够在没有任何数据的情况下从一个部分切换到另一个部分。


我有一些简单的javascript改变了div标签上的样式attrs(一个onclick

事件在标签上),这个工作正常。


一次用户完成表单,点击提交,理论上整个表单是

提交。问题是当使用NS6.x浏览器(此项目的要求是
)时,任何位于隐藏div标签中的表单字段(< div style =" display:none">)

被视为不存在。这对IE6 +和NS7.x +来说不是问题。


任何帮助都会很棒!

谢谢,

Dan

解决方案

" Dan R Brown" < dr*@TheWorld.com>在消息中写道

news:bg ********** @ pcls4.std.com ...

< snip>

...,点击提交,理论上提交了整个表格。问题是当使用NS6.x浏览器时(这个项目的要求),任何表单字段
驻留在隐藏的div标签中
(< div style =" display:none" ;>)被视为不存在。
这不是IE6 +和NS7.x +的问题。




我假设我可以启动安装了Netscape 6.2

的机器,创建一个测试页面并自己查找但是...


你在说什么在DIV元素中包含的表单元素

具有指定display:none的样式属性;物业不是随表格一起提交的,或者在提交表格时将其风格

属性设置为无的DIV不是

包括(或两者)?

如果问题与HTML中样式初始设置相关联,那么你就是b $ b属性可能不应该这样做

无论如何[1]。有可能让XSLT创建一个onload

处理函数,在

页面上设置DIV的初始显示状态。


如果在提交表格

时问题与显示属性的状态有关,则应该可以在

页面上显示所有DIV按下提交按钮。


[1]使用JavaScript设置初始显示

属性的原因是您需要按顺序提供JavaScript

再次透露他们。如果CSS设置了初始显示状态,那么任何

style =" display:none;"在客户端上没有JavaScript的情况下,元素永远不可用。


重要程度可能取决于<的确切措辞br />
您的规格。你说规范需要支持

Netscape 6.x.如果你的规范确实要求支持

启用JavaScript的Netscape 6.x (或Net 6的默认配置或类似的东西)然后你就可以制作一个

JavaScript依赖的网站并符合规范。但是,如果

规范仅规定了支持Netscape 6.x的要求(包括任何其他浏览器的

)那么它可能是合理的

被解释为要求Netscape 6.x支持任何及所有

用户可配置状态。那些用户可配置的状态当然是

包括关闭JavaScript的选项(还有很多其他的

)。


我对规范的经验表明,它们支持与客户签订的一系列合同所需的浏览器支持。如果

合约指定浏览器(仅限)那么对于

a客户来说,发现他们已经被提供了一个JavaScript
$ b $是不合理的。 b依赖网站,回来说,你知道浏览器是

可以配置当你同意支持它时,只支持浏览器

in * one *它的配置是不可接受的,请回去修理它或者我们不会付钱的。
。如果他们这样做的话,我认为他们能够在法庭上提出一个好的案子,如果有的话。


Richard。


Richard Cornford< Ri ***** @ litotes.demon.co.uk>写道:路径:!!!!!nntp.TheWorld.com newsfeed.mathworks.com kibo.news .demon.net news.demon.co.uk妖不以邮件
来自:Richard Cornford < Ri ***** @ litotes.demon.co.uk>
新闻组:comp.lang.javascript
主题:Re:使用< div style ="隐藏的表单元素的问题; display:none">
日期:星期五,2003年8月1日01:48:03 +0100
行:62
消息ID:< bg ******* ************@news.demon.co.uk>
参考文献:< bg ********** @ pcls4.std.com>
NNTP-Posting-Host:litotes.demon.co.uk
X-Trace:news.demon.co.uk 1059698886 15881 212.229.126.254(2003年8月1日00:48:06 GMT)
X -Complaints-To: ab***@demon.net
NNTP-Posting-Date:2003年8月1日星期五00 :48:06 +0000(UTC)
X-MimeOLE:微软MimeOLE制作V6.00.2800.1106
X-Priority:3
X-Newsreader:Microsoft Outlook Express 6.00.2800.1106
X-MSMail-Priority:正常
外部参照:nntp.TheWorld.com comp.lang.javascript :417338
" Dan R Brown" < dr*@TheWorld.com>在消息中写道
新闻:bg ********** @ pcls4.std.com ...
< snip>

...,the点击提交,理论上提交整个表格。问题是当使用NS6.x浏览器时(这个项目的要求),任何表单字段
驻留在隐藏的div标签中
(< div style =" display:none" ;>)被视为不存在。
这不是IE6 +和NS7.x +的问题。


我想我可以启动机器我已经安装了Netscape 6.2,创建一个测试页面并自己查找但是...
你是说DIV元素中包含的表单元素
具有指定显示的样式属性:没有;财产不是随表格提交的,或者提交表格时其风格
属性设置为无的DIV不包括在内(或两者兼而有之)?
如果问题与HTML中样式属性的初始设置有关,那么你可能不应该这样做
[1]。可以让XSLT创建一个onload
处理函数,在
页面上设置DIV的初始显示状态。
如果问题与提交表格
时显示属性的状态有关,那么当按下提交按钮时,应该可以在
页面上显示所有DIV。
[1]使用JavaScript设置初始显示属性的原因是您需要使用JavaScript才能再次显示它们。如果CSS设置初始显示状态,那么任何
style =" display:none;"在客户端上没有JavaScript的情况下,元素永远不可用。
重要程度可能取决于您的规格的确切措辞。你说规范要求支持Netscape 6.x.如果您的规范实际上声明要求支持
启用JavaScript的Netscape 6.x (或Net 6的默认配置,或类似的东西),那么你将能够建立一个
JavaScript依赖的网站,并符合规范。但是,如果
规范仅规定了支持Netscape 6.x的要求(与包含任何其他浏览器的
),则可以合理地解释为需要支持Netscape 6.x in任何和所有用户可配置的状态。那些用户可配置的状态当然包括关闭JavaScript的选项(除此之外还有很多其他功能)。
我对规范提供一系列所需浏览器支持的经验是,它们与客户签订了合同。如果
合同指定了浏览器(仅限)那么对于客户来说,发现他们已经被提供了一个依赖于JavaScript的网站,回来说是,这对他们来说是不合理的。 ;当你同意支持它时,你知道浏览器是可配置的,只支持浏览器
* *其中一个配置是不可接受的,回去修复它或
我们赢了不付钱。如果他们这样做了,我认为他们能够在法庭上提出一个好的案子,如果是这样的话。
Richard。




使用< div>的原因标签是将表单的部分隐藏或显示给

用户。每个< div>根据与

信息相关的顶部或类别对表单进行分区。当用户首先导航到页面时,通用按钮被导向页面。显示部分是

,而所有其他部分都隐藏在视图中(xslt在< div>标记中设置正确的

样式。如果用户希望看到另一个部分(即xyz

设置),他们点击xyz设置选项卡/按钮。有javascript

与页面相关联,将设置样式之前查看的部分

隐藏,然后显示表单的xyz设置部分。这一切都有效。

罚款。


什么不起作用(使用NS6.x)是在提交表单时,任何表单元素

在< div style = display:none>标签中隐藏,不要发送(发布或

得到......这没关系).NS6.x将那些表单元素视为不存在于

页面,实际上他们确实这样做了。


在提交工作之前公开所有< div>标签的建议,但它是

在我们的产品中不可接受的主要眼睛(这不是一个网站,而是用于配置的基于浏览器的用户界面)。


至于规范是,NS6.x是一个要求...并且javascript必须是

启用。问题不在于规范...它与NS6.x如何处理css元素有关。


感谢您的回复

Dan


在文章< bg ********** @ pcls4.std.com> ;, Dan R Brown< dr*@shell01.TheWorld.com> ;

写道:

什么不起作用(使用NS6.x)是表单提交时,
任何表单元素是隐藏在< div style = display:none>
标签内的视图,不要发送(发布或获取......这没关系)。 NS6.x将那些
表单元素视为在页面上不存在,而事实上它们就是这样。


对于你和IE,他们可能存在,但对NS来说,他们不会。

暴露所有< div>的建议标签,在提交作品之前,但它是我们产品中不可接受的主要眼睛(不是
网站,而是基于浏览器的配置用户界面)。

就规范而言,NS6.x是一项要求......并且必须启用javascript
。问题不在于规范......它与NS6.x处理css元素的方式有关。




使用隐藏的表单获取提交。在每个领域的变化,让它设置其对应的隐藏对应物。然后提交隐藏的字段表格。


-

Randy

发布的所有代码都取决于查看浏览器

支持调用的方法,并启用Javascript。


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

解决方案

"Dan R Brown" <dr*@TheWorld.com> wrote in message
news:bg**********@pcls4.std.com...
<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.


Richard Cornford <Ri*****@litotes.demon.co.uk> wrote:

Path: nntp.TheWorld.com!newsfeed.mathworks.com!kibo.news .demon.net!news.demon.co.uk!demon!not-for-mail
From: "Richard Cornford" <Ri*****@litotes.demon.co.uk>
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: <bg*******************@news.demon.co.uk>
References: <bg**********@pcls4.std.com>
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: ab***@demon.net
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" <dr*@TheWorld.com> wrote in message
news:bg**********@pcls4.std.com...
<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


In article <bg**********@pcls4.std.com>, Dan R Brown <dr*@shell01.TheWorld.com>
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.
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 website, 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.



Use a hidden form that gets submitted. onchange of every field, have it set its
corresponding hidden counterpart. Then submit the hidden fields form.

--
Randy
All code posted is dependent upon the viewing browser
supporting the methods called, and Javascript being enabled.


这篇关于使用&lt; div style =&quot; display:none&quot;&gt;隐藏的表单元素的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆