根据表单中的值动态更改表单提交按钮?
这应该很容易,但是在浏览了几个库(jquery 首选!)甚至普通的旧 JavaScript 后,我一片空白。
换句话说,一行有 3 个编辑框,其中 2 个预先填充了奶酪和泡菜的类型,然后是一个未填充的数字框,右侧有一个提交按钮。 重复n次n行。
换句话说: 想象一下,一个表单呈现为搜索结果中的一系列行。 假设有 8 个结果,即 8 行。用户可以将他们的选择保存到 100 个“槽”中的任意一个中。 如果每一行都可以有一个名字或字母,那就很容易了;我只是将每个提交按钮称为一个数字,从 1 到 8,当按下 6 时,它知道它要保存的是第 6 行。它使用 Malsup 的 jquery 表单以 ajaxy 方式提交,这样表单就不必每次都刷新。
但这不允许自由选择结果保存在哪个“槽”中。如果我能让提交按钮反映其左侧单元格中的数字,我就会离开。
但我不能,所以我不是。而我似乎是唯一一个做出这种无稽之谈的人。 还有更好的办法吗?
This should be easy, but after browsing several libraries (jquery preferred!) and even plain old javascript, I'm drawing a blank.
In other words, a row with 3 edit boxes, 2 prefilled with type of, say, cheese and pickle, then one unfilled box for a number, and a submit button to the right of that.
Repeat times n rows.
To put it another way:
Imagine a form presented as a series of rows from a search result.
Let's say there are 8 results, that's 8 rows. The user can save their choices into any of 100 "slots".
It's easy if each row can have a name or letter; I just call each submit button a number, 1 to 8, and when say 6 is pressed, it know it's row 6 it wants to save. It uses Malsup's jquery form thing to submit it in an ajaxy way so that the form doesn't have to be refreshed each time.
But that doesn't allow free choice of which "slot" that result is saved in. If I could get the submit button to reflect the number in the cell to the left of it, I'd be away.
But I can't, so I'm not. And I appear to be the only person to do such a nonsense thing.
Any better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们假设您的提交按钮是一个按钮元素。
//现在你的所有formData都在一个对象中。通过您的 Ajax 设备发送它。
Let's assume your submit button is a button element.
//Now you have all your formData in an object. Send it via your Ajax thing.