如何更新表单“项目名称”从下拉列表中选择一个项目
当选择下拉菜单中的项目时,是否可以更新表单中的隐藏值“项目名称”?
<input type="hidden" name="item_name" value="PHOTOID 2 Product MUG" />
下拉列表:(从 datase 填充。mug
£9.99
a4 print £2.50
等
ID
当选择一个项目时,但在按下“添加到购物车”按钮之前,可以更新 item_name 值?否则我只会收到发送的照片 到购物车。这会将商品添加到 paypal 购物车,我只能有一个商品名称,然后是下面填充的选项列表,谢谢
。
Is it possible to update a hidden value "item name" in a form when an item in the drop down menu is selected?
<input type="hidden" name="item_name" value="PHOTOID 2 Product MUG" />
Drop Down List: (populated from datase.
mug £9.99
a4 print £2.50
etc
etc
When an item is selected, but before the add to cart button is pressed it is possible to update the item_name value? Otherwise I just get the photo ID sent to the cart. This adds the item to paypal shopping cart, I can only have one item name then the populated options list below. I hope that makes sense.
Thank in advance :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您的下拉菜单是
If your drop-down menu is a
<select>
tag, then you can do the following:你可以用 javascript 来做到这一点,但我不太清楚为什么你需要这样做。如果您有一个带有值的选择和一个隐藏字段,该隐藏字段应该采用与选择相同的值,那么这意味着您将提交相同的数据两次。直接使用select控件的值就可以了。
You could do it with javascript, but I'm not quite sure why you'd need to. If you have a select with values and a hidden field that's supposed to take the same value as the select, then that mean you're submitting the same data twice. Just use the value of the select control directly.
用 javascript 很容易做到;对于 jQuery 来说微不足道。假设我们有以下 html:
您要做的是:
这意味着:
当用户单击 id item-list 的元素包含的 li 时
分配给 id the_id 的元素,作为名称,他们刚刚单击的 li 包含的文本。
抱歉,我刚刚意识到您想更改名称而不是值:固定。
It's pretty easy to do in javascript; trivial with jQuery. Let's pretend we have the following html:
What you would do is:
That means:
as the user clicks on a li contained by the element with id item-list
assign to the element with id the_id, as name, the text contained by the li they just clicked.
Sorry, I just realized you wanted to change the name and not the value: fixed.