动态页面构建 [英] Dynamic Page Building

查看:80
本文介绍了动态页面构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有两个单选按钮的表单。当第一个单击时,我希望页面刷新(保持表单数据为

),然后显示需要填写的2个新字段。如果单击第二个按钮

,我需要发生同样的事情,只有它

将显示两个需要填写的不同字段。


有没有人有代码可以做到这一点?或者甚至可以用

JavaScript吗?


谢谢!!

I have a form that has two radio buttons. When the first one is
clicked, I would like the page to refresh (keeping the form data in
tact) and then displaying 2 new fields that need to be filled out. If
the second button is clicked, I need the same thing to happen, only it
will display two different fields needing to be filled out.

Does anyone have code that will do this? Or is this even possible with
JavaScript?

Thanks!!

推荐答案

最简单的方法是将2个新字段放在块元素中,例如

div,将它们的初始样式设置为

display:none,然后使用单选按钮有一个onclick事件处理程序

设置适当的div显示:block和另一个div

display:none。然后就没有必要刷新。


Jen写道:
Easiest way would be to put the 2 new fields in block elements like
divs, set their initial style to
display:none, then with the radio buttons have an onclick event handler
that sets the appropriate div to display:block and the other div to
display:none. Then there is no refreshing required.

Jen wrote:

>

我有一个有两个单选按钮的表单。当第一个单击时,我希望页面刷新(保持表单数据为

),然后显示需要填写的2个新字段。如果单击第二个按钮

,我需要发生同样的事情,只有它

将显示两个需要填写的不同字段。


有没有人有代码可以做到这一点?或者这可以用

JavaScript吗?


谢谢!
>
I have a form that has two radio buttons. When the first one is
clicked, I would like the page to refresh (keeping the form data in
tact) and then displaying 2 new fields that need to be filled out. If
the second button is clicked, I need the same thing to happen, only it
will display two different fields needing to be filled out.

Does anyone have code that will do this? Or is this even possible with
JavaScript?

Thanks!!


您可以使用基本的DOM脚本轻松完成此操作。您可以根据用户操作添加和删除

HTML元素 - 即:点击特定的收音机

按钮。


使用display:none的问题即使它是'

" hidden"从视图来看,它仍然代表屏幕空间,即:

页面上的GAP实际上是HTML内容,如果有意义的话。


DOM脚本是要走的路。你可以完全控制很多东西。


加里·哈斯勒写道:
You can easily do this with basic DOM scripting. You can add and remove
HTML elements, based on a users action - ie: clicking a specific radio
button.

The problem with using "display: none" is that even though it''s
"hidden" from view, it still represents screen space, ie: a GAP on the
page where the HTML content actually is, if that makes sense.

DOM scripting is the way to go. You have full control over many things.

Gary Hasler wrote:

最简单的方法是放置2个新字段在块元素如

divs中,将它们的初始样式设置为

display:none,然后使用单选按钮有一个onclick事件处理程序

将相应的div设置为:block和另一个div为

display:none。然后就没有必要刷新了。


Jen写道:
Easiest way would be to put the 2 new fields in block elements like
divs, set their initial style to
display:none, then with the radio buttons have an onclick event handler
that sets the appropriate div to display:block and the other div to
display:none. Then there is no refreshing required.

Jen wrote:


我有一个有两个收音机的表格纽扣。当第一个单击时,我希望页面刷新(保持表单数据为

),然后显示需要填写的2个新字段。如果单击第二个按钮

,我需要发生同样的事情,只有它

将显示两个需要填写的不同字段。


有没有人有代码可以做到这一点?或者这可以用

JavaScript吗?


谢谢!

I have a form that has two radio buttons. When the first one is
clicked, I would like the page to refresh (keeping the form data in
tact) and then displaying 2 new fields that need to be filled out. If
the second button is clicked, I need the same thing to happen, only it
will display two different fields needing to be filled out.

Does anyone have code that will do this? Or is this even possible with
JavaScript?

Thanks!!


Matthom写道:


热门帖子的热门帖子,请不要!
Matthom wrote:

Top posting on top posting, please don''t!

Gary Hasler写道:
Gary Hasler wrote:

>> Jen写道:
>>Jen wrote:

>>>我有一个有两个单选按钮的表单。单击第一个时,我希望页面刷新(保持表格数据),然后显示需要填写的2个新字段。如果点击第二个按钮,我需要做同样的事情,只有它会显示需要填写的两个不同的字段。

有没有人会有代码做这个?或者这是否可以使用
JavaScript?
>>>I have a form that has two radio buttons. When the first one is
clicked, I would like the page to refresh (keeping the form data in
tact) and then displaying 2 new fields that need to be filled out. If
the second button is clicked, I need the same thing to happen, only it
will display two different fields needing to be filled out.

Does anyone have code that will do this? Or is this even possible with
JavaScript?


最简单的方法是将2个新字段放在块元素中,例如
div,将它们的初始样式设置为
display:none,然后用单选按钮有一个onclick事件处理程序
设置相应的div来显示:block和另一个div
display:none。然后不需要刷新。

Easiest way would be to put the 2 new fields in block elements like
divs, set their initial style to
display:none, then with the radio buttons have an onclick event handler
that sets the appropriate div to display:block and the other div to
display:none. Then there is no refreshing required.



您可以使用基本的DOM脚本轻松完成此操作。您可以根据用户操作添加和删除

HTML元素 - 即:点击特定的收音机

按钮。


使用display:none的问题即使它是'

" hidden"从视图来看,它仍然代表屏幕空间,即:

页面上的GAP实际上是HTML内容,如果有意义的话。


You can easily do this with basic DOM scripting. You can add and remove
HTML elements, based on a users action - ie: clicking a specific radio
button.

The problem with using "display: none" is that even though it''s
"hidden" from view, it still represents screen space, ie: a GAP on the
page where the HTML content actually is, if that makes sense.



否," display:none"从页面中删除元素。

No, "display: none" removes the element form the page.


DOM脚本是可行的方法。你可以完全控制很多

的东西。
DOM scripting is the way to go. You have full control over many
things.



使用可见和不可见的CSS类并交换< br $>
元素的类名。


-

Ian Collins。

It''s easier just to use a visible and invisible CSS class and swap the
element''s class name.

--
Ian Collins.

这篇关于动态页面构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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