确定。我不知道我在做什么。我要回去帮助人们找工作。我在小提琴中运行了所有内容,并将其迁移到两个不同的编辑器,一切都很好,但没有任何反应,没有警报,也没有提交的onclick。我在笔记本电脑上试了一下,两个页面上显示了一个带有profilebannerIE,另一个带有html。再次感谢。
老人jquery。我们有一个表格,我们希望人们填写并提交。形式并不难创造,但现在我们希望它做一些特殊的事情。我已经研究并尝试了3天不同的事情,这是我最后的努力。您的许多论坛想法都非常聪明,我相信您可以在瞬间实现这一点。提前谢谢!
如果七个或更多单选按钮被点击“是”,我们正试图获取以下表单上的提交按钮以转到“网站1”。如果答案少于7个“是”,我们希望它转到“网站2”。
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>Survey</title>
</head>
<body>
<h1 style="text-align: center;"><big><span
style="font-family: Arial Unicode MS; background-color: white; color: rgb(0, 0, 153);">Survey</span></big></h1>
<div
style="text-align: center; font-family: Arial Unicode MS; color: rgb(0, 0, 153); font-weight: bold;"><big>Please
answer the following questions and click the 'Submit' button at the bottom of the page.</big></div>
<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?<br>
<input name="Documents" value="Yes" type="radio">Yes<br>
<input name="Documents" value="No" type="radio">No<br>
<br>
Do you have a resume?<br>
<input name="Resume" value="Yes" type="radio">Yes<br>
<input name="Resume" value="No" type="radio">No<br>
<br>
Do you have reliable transportation?<br>
<input name="transportation" value="Yes" type="radio">Yes<br>
<input name="transportation" value="No" type="radio">No<br>
<br>
Do you have a high school diploma or equivalent?<br>
<input name="Diploma" value="Yes" type="radio">Yes<br>
<input name="Diploma" value="No" type="radio">No<br>
<br>
Do you have an occupational license, certification, or advanced level of education?<br>
<input name="Cert" value="Yes" type="radio">Yes<br>
<input name="Cert" value="No" type="radio">No<br>
<br>
Have you been unemployed longer than 6 months?<br>
<input name="Unemployed" value="Yes" type="radio">Yes<br>
<input name="Unemployed" value="No" type="radio">No<br>
<br>
Have you had more than three jobs within the last two years?<br>
<input name="Jobs" value="Yes" type="radio">Yes<br>
<input name="Jobs" value="No" type="radio">No<br>
<br>
Do you have appropriate interview clothing?<br>
<input name="Clothing" value="Yes" type="radio">Yes<br>
<input name="Clothing" value="No" type="radio">No<br>
<br>
Do you have a criminal background?<br>
<input name="Background" value="Yes" type="radio">Yes<br>
<input name="Background" value="No" type="radio">No<br>
<br>
<input name="Submit" value="Submit" type="submit"><small><br>
<br>
<br>
</form>
</body>
</html>
答案 0 :(得分:1)
为了供将来参考,有一个名为jsFiddle的漂亮工具,您可以使用它来为我们提供更好的代码:jsFiddle
我已经为你做了一个快速的解决方案,应该让你开始here
var answered_yes = 0;
$("input[type=radio]:checked").each(function() {
if ($(this).val() === "Yes") {
answered_yes++;
}
});
if (answered_yes >= 7) {
location.href = "7 or more website.html";
} else {
location.href = "less than 7 website.html";
}
这是你可以使用的标记(包含CDN中的jQuery库),你的标记需要相当多的工作,但你已经明确表示你是一个初学者,所以我会给你一个骨头。看看你是否能够进一步了解这一点。
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Survey</title>
</head>
<body>
<h1 style="text-align: center;">
<big><span style="font-family: Arial Unicode MS; background-color: white; color: rgb(0, 0, 153);">Survey</span></big>
</h1>
<div style="text-align: center; font-family: Arial Unicode MS; color: rgb(0, 0, 153); font-weight: bold;">
<big>Please answer the following questions and click the 'Submit' button at the bottom of the page.</big>
</div>
<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?<br>
<input name="Documents" value="Yes" type="radio">Yes<br>
<input name="Documents" value="No" type="radio">No<br>
<br>Do you have a resume?<br>
<input name="Resume" value="Yes" type="radio">Yes<br>
<input name="Resume" value="No" type="radio">No<br>
<br>Do you have reliable transportation?<br>
<input name="transportation" value="Yes" type="radio">Yes<br>
<input name="transportation" value="No" type="radio">No<br>
<br>Do you have a high school diploma or equivalent?<br>
<input name="Diploma" value="Yes" type="radio">Yes<br>
<input name="Diploma" value="No" type="radio">No<br>
<br>Do you have an occupational license, certification, or advanced level of education?<br>
<input name="Cert" value="Yes" type="radio">Yes<br>
<input name="Cert" value="No" type="radio">No<br>
<br>Have you been unemployed longer than 6 months?<br>
<input name="Unemployed" value="Yes" type="radio">Yes<br>
<input name="Unemployed" value="No" type="radio">No<br>
<br>Have you had more than three jobs within the last two years?<br>
<input name="Jobs" value="Yes" type="radio">Yes<br>
<input name="Jobs" value="No" type="radio">No<br>
<br>Do you have appropriate interview clothing?<br>
<input name="Clothing" value="Yes" type="radio">Yes<br>
<input name="Clothing" value="No" type="radio">No<br>
<br>Do you have a criminal background?<br>
<input name="Background" value="Yes" type="radio">Yes<br>
<input name="Background" value="No" type="radio">No<br>
<br><input name="Submit" value="Submit" type="submit"><small><br>
<br>
<br>
</form>
<script type="text/javascript" href="http://code.jquery.com/jquery-1.10.0.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("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) {
location.href = "7 or more website.html";
} else {
location.href = "less than 7 website.html";
}
});
});
</script>
</body>
</html>
答案 1 :(得分:0)
您可以尝试以下代码来获取已选中单选按钮的计数,其示例代码
HTML
<label><input type="radio" value="1" name="rdQueen" /> Scaramouche</label> <br />
<label><input type="radio" value="1" name="rdQueen" /> Will you do the</label> <br />
<label><input type="radio" value="1" name="rdQueen" /> Fandango</label> <br />
<label><input type="radio" value="1" name="rdFruit" /> Mango</label> <br />
<label><input type="radio" value="1" name="rdFruit" /> Kiwi</label> <br />
<label><input type="radio" value="1" name="rdFruit" /> Potato</label> <br />
<button id="test">Run test</button>
的jQuery
$('#test').click(function(){
if($(':radio[name=rdQueen]:checked, :radio[name=rdFruit]:checked').length == 2)
alert('good to go');
else
alert('please choose one from each group');
});