使用JavaScript有条件地提交表单 [英] Submitting forms conditionally using JavaScript

查看:64
本文介绍了使用JavaScript有条件地提交表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我发现了一篇关于developertutorials.com的优秀文章,名为:使用JavaScript有条件地提交表单。它告诉我如何使用一组单选按钮编写一个简单的表单,根据输入有条件地提交。


有没有办法创建一个包含多组单选按钮的表单还会有条件地使用JavaScript提交吗?


我正在尝试在我的网站上设置一个表单,以便用户在订购相册时从几个选项中进行选择,这是我不喜欢的产品还没提供。例如,单选按钮组将要求用户选择:横向/纵向;打印的页码/没有打印的页码;和三/四种不同的布局。


任何对此的帮助都将非常感激。


亲切的问候,


Mark

Hi,

I found an excellent article on developertutorials.com entitled: "Submitting forms conditionally using JavaScript." It told me how to write a simple form with one set of radio buttons that submits conditionally based on the input.

Is there a way of creating a form with multiple sets of radio buttons that will also submit conditionally, using JavaScript?

I am trying to set up a form on my website to enable users to select from a few options when ordering photobooks, a product I don''t yet offer. The sets of radio buttons would ask, for example, the user to choose between: landscape/portrait; printed page numbers/no printed page numbers; and three/four different layouts.

Any help with this would be most appreciated.

With kind regards,

Mark

推荐答案

是的。如果你可以用一组单选按钮来完成它。您可以使用多组单选按钮来完成。这是我能得到的具体信息,因为你还没有描述他们如何交互多组单选按钮。但是很有可能你只会在教程中使用相同的代码,除非条件更复杂。
Yes. If you can do it with one set of radio buttons. You can do it with more than one set of radio buttons. That''s as specific as I can get because you haven''t described how they multiple sets of radio buttons are supposed to interact. But most likely you will just use the same code in the tutorial except with more complex conditions.


你好兔子,


感谢您的回复。


我希望实现的目标如下:


客户访问我的网站并想订购相簿。从可用选项中,他们选择横向,打印页码和布局三。当客户点击提交按钮时,他们会被带到商店网站上的相应页面来订购他们刚刚选择的商品。


如果另一位客户出现并做出不同的选择,他们将被提交到不同的网页上。


我对JavaScript很陌生,所以我不知道应该使用哪些术语。


提前感谢您提供任何其他帮助。
Hi Rabbit,

Thanks for your response.

What I am looking to achieve is something like the following:

A customer visits my site and wants to order a photobook. From the options available, they choose a landscape orientation, printed page numbers, and layout three. When the customer hits the submit button, they are taken to the appropriate page on the shop website to order what they have just chosen.

If another customer comes along and makes a different selection, they will be taken to a different webpage on submit.

I am really new to JavaScript so have very little idea what terms I should use.

Thanks in advance for any additional help.


基本上与教程所说的相同,只需更改if子句中的条件以符合您的条件。
Basically do the same thing that the tutorial says, just change the conditions in the if clauses to match your conditions.


这篇关于使用JavaScript有条件地提交表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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