用户输入字段可以更好地使用DIV或仅计算公式的网页表单? [关闭]
I want to have 6 input fields in a webpage. If the user presses a button the 6 fields expand to 7,8, 9, or 10 fields. The fields are editable and come with a preset value. With the input from the user (or the preset values) a final value is calculated via a formula.
- Is it better to use a
form
for the fields orDIV
s? - Should I use
JavaScript
or something else I am not thinking about yet? - Should I use
AJAX
when getting the values or is it not needed in this case? - I thought about using an excel like editor made with
jQuery
https://github.com/mleibman/SlickGrid/wiki/Examples but it seems overkill for my needs plus I would need to edit a lot of it since I want a simple display of the fields.
我想在网页中有6个输入字段。 如果用户按下按钮,则6个字段将扩展为7,8,9或10个字段。 这些字段是可编辑的,并带有预设值。 使用来自用户的输入(或预设值),通过公式计算最终值。 p>
- 使用
表单是否更好 code >对于字段或
DIV code> s? li>
- 我应该使用
JavaScript code>或其他我还没想到的其他内容吗? li> \ n
- 在获取值时我应该使用
AJAX code>还是在这种情况下不需要? li>
- 我考虑使用由
编写的类似excel的编辑器 jQuery code> https://github.com/mleibman/SlickGrid/wiki/Examples但是对于我的需求似乎有点过分,而且我需要编辑很多,因为我想要一个简单的字段显示。 li> ol> div>
- 我应该使用
I would use a form as you're asking the users for their data to be input. This will also trigger the keyboard on mobile/tablet devices if you're also targeting those platforms.
Javascript is fine for this, unless you want to hide the formula you're using (as they will be able to see it if they view your source).
Do you need to use AJAX? Are the pre-populated values going to change that much? If not, then no, it's just adding extra work when you could just have an array of values.