简体   繁体   English

如何在表单中包含元素但在布局中将其物理分离

[英]How do I include an element in a form but separate it physically in the layout

So given a layout like so:所以给定这样的布局:

在此处输入图像描述

How can I include the value of ComboBox in the submission of the form.如何在提交表单中包含 ComboBox 的值。

Things that have occurred to me:发生在我身上的事情:

  1. Include the combo box as part of the form in terms of markup and position it absolutely.在标记和 position 方面绝对包括组合框作为表单的一部分。 I'm don't get how this would work if the page needs to resize and the combo should remain where it it is in this title bar.如果页面需要调整大小并且组合应保留在此标题栏中的位置,我不明白这将如何工作。
  2. On submission use JS to grab the value and insert it in a hidden field as part of the form submission.提交时使用 JS 获取值并将其插入到隐藏字段中,作为表单提交的一部分。 This would clearly break without JS but the page is client facing and we are willing to stipulate that JS is required.如果没有 JS,这显然会中断,但是页面是面向客户端的,我们愿意规定 JS 是必需的。

I believe I have stated all the restrictions so given that is there another approach?我相信我已经说明了所有限制,因此还有另一种方法吗? If not how should I choose between the above options?如果不是,我应该如何在上述选项之间进行选择?

With out seeing some HTML its hard to determine the layout you have.没有看到一些 HTML 很难确定你的布局。 But my first thought would be to use Absolute positioning with CSS.但我的第一个想法是使用 CSS 的绝对定位

The other option would be to incorporate the entire page as a part of the form, but this may not be possible due to other functionality on the page that may be necessary另一种选择是将整个页面合并为表单的一部分,但这可能是不可能的,因为页面上可能需要其他功能

You obviously could use aa giant form tag.你显然可以使用一个巨大的表单标签。

OR或者

Two forms, changing the combo and submitting does a full post and adds a hidden to the main form.两个 forms,更改组合并提交完整的帖子并在主窗体中添加一个隐藏。 Then sexy it up with JavaScript (prevent the full post back, and remove the submit button on the combo form)然后用 JavaScript 性感起来(防止完整的回帖,并删除组合表单上的提交按钮)

OR或者

CSS Positioning as you suggest. CSS 按照您的建议定位。

I would say use javascript.我会说使用 javascript。

  1. have a hidden input field in the form.在表单中有一个隐藏的输入字段。
  2. on page load, that input is populated with the ComboBox value.在页面加载时,该输入将填充 ComboBox 值。
  3. update the value if the ComboBox select is changed.如果 ComboBox select 更改,则更新该值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM