提交按钮到或然页面 [英] submit button to contingent pages

查看:81
本文介绍了提交按钮到或然页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

确定。我不知道我在做什么。我要回去帮助人们找工作。我在小提琴中运行了所有东西,并将它移植到两个不同的编辑器中,一切都显示正常,但没有任何反应,没有警报,也没有onclick提交。我在我的笔记本电脑上试了一下,两页用profilebannerIE显示出来,另一页用html显示。再次感谢。

jquery的新手。我们有一个表格,我们希望人们填写和提交。表格并不难创建,但现在我们希望它做一些特殊的事情。我已经研究并尝试了3天不同的事情,这是我最后的努力。很多论坛的想法都非常聪明,我相信你们可以在瞬间完成这个工作。

我们正在尝试将下列表单上的提交按钮转到网站1,如果单击了七个或更多单选按钮是。如果答案少于7个,我们希望它转到网站2。

 < form method =postaction =http://www.workintexas.com
name =客户调查>< br>
您目前是否在职?< br>
< input name =Employedvalue =Yestype =radio>是< br>
< input name =Employedvalue =Notype =radio>否< br>
< br>
您是否有可用的文件来支持您的授权

在美国工作?








你有简历吗?



没有



您有可靠的交通工具吗?



不是



您是否拥有高中毕业文凭或同等学历?







您是否拥有职业执照,认证,还是先进水平的
教育?







您是否失业超过6个月?







您在过去两年内有超过三份工作吗?



没有



您是否有合适的面试服装?







您有犯罪背景吗?



不是











  $(input [type = submit])。bind(click ,function(e){
e.preventDefault();
varwered_yes = 0;
$(input [type = radio]:checked)。each(function(){
if($(this).val()===Yes){
answers_yes ++;
}
});
if(answers_yes> = 7){
alert(7或更多回答是);
} else {
alert(少于7回答是);
}
});


解决方案

查看长度选中的单选按钮的属性!



JavaScript / jQuery



  if($('input [type =radio]:checked')。length> = 7)
alert(超过七个或七个!);
else
alert(少于七!);



JSFiddle实时演示






最终代码(包含重定向): p>

JavaScript / jQuery



  $(input [type = submit] ).bind(click,function(e){
e.preventDefault();
if($('input [type =radio]:checked')。length> = 7 )
window.location.href =http://stackoverflow.com;
else
window.location.href =http://codereview.stackexchange.com/;
});


Ok. I don't know what I'm doing. I'm going to go back to helping people find jobs. I ran everything in the Fiddle and migrated it over to two different editors and everything shows up fine, but nothing happens, no alerts, no onclick to submit. I tried it on my laptop and two pages showed up one with profilebannerIE on it and the other with the html. Thanks again.

Old man new to jquery. We have a form that we would like for folks to fill out and submit. The form was not difficult to create, but now we would like it to do some special things. I've researched and tried different things for 3 days and this is my last ditch effort. Many of your forum ideas are very clever and I'm sure ya'll can get this to work in a flash. Thanks in advance!

We are trying to get the submit button on the following form to go to "website 1" if seven or more of the radio buttons are clicked "yes". If there are less than 7 "yes" answers we would like it to go to "website 2".

<form method="post" action="http://www.workintexas.com"
 name="Customer Survey"><br>
Are you currently employed?<br>
  <input name="Employed" value="Yes" type="radio">Yes<br>
  <input name="Employed" value="No" type="radio">No<br>
  <br>
Do you have readily available, documents to support your authorization

to work in the USA?
Yes
No

Do you have a resume?
Yes
No

Do you have reliable transportation?
Yes
No

Do you have a high school diploma or equivalent?
Yes
No

Do you have an occupational license, certification, or advanced level of education?
Yes
No

Have you been unemployed longer than 6 months?
Yes
No

Have you had more than three jobs within the last two years?
Yes
No

Do you have appropriate interview clothing?
Yes
No

Do you have a criminal background?
Yes
No




$("input[type=submit]").bind("click", function (e) {
    e.preventDefault();
    var answered_yes = 0;
    $("input[type=radio]:checked").each(function () {
        if ($(this).val() === "Yes") {
            answered_yes++;
        }
    });
    if (answered_yes >= 7) {
        alert("7 or more answered yes");
    } else {
        alert("less than 7 answered yes");
    }
});

解决方案

Look at the length property of the checked radio buttons!

JavaScript/jQuery

if($('input[type="radio"]:checked').length >=7)
    alert("More than seven OR seven!");
else
    alert("Less than seven!");

JSFiddle live demo


Final code (with redirections):

JavaScript/jQuery

$("input[type=submit]").bind("click", function (e) {
    e.preventDefault();
    if ($('input[type="radio"]:checked').length >= 7)
        window.location.href = "http://stackoverflow.com";
    else 
        window.location.href = "http://codereview.stackexchange.com/";
});

这篇关于提交按钮到或然页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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