- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在进行一个项目,正在为网站上的用户进行调查。用户可以单击“后退”按钮,将他带到上一个问题,也可以单击“下一个”按钮,将他带到下一个问题。
所有这些问题都在同一个父 div 中,并分为各自的 div。所以它们都在同一页面中。我为父 div 中的每个问题 div 赋予隐藏和显示属性,以便根据用户单击下一步和返回来显示相关问题。因此,如果用户单击“下一步”,我将隐藏当前问题 div 并显示下一个问题 div。当用户单击后退按钮时反之亦然。
HTML
<div class="question-box">
<div class="progress-bar">
<h3 id="percent">7%</h3>
</div>
<div id="one" class="question">
<p>On a scale of 0-5, where 0 is not at all likely and 5 is extremely likely:</p>
<p>How likely are you to recommend Classic Screenings Cinema to someone else?</p>
<div class="answer">
<ul>
<li>0</li>
<li><input type="radio" autocomplete="off"" name="q0" value="0"></li>
</ul>
<ul>
<li>1</li>
<li><input type="radio" autocomplete="off" name="q0" value="1"></li>
</ul>
<ul>
<li>2</li>
<li><input type="radio" autocomplete="off" name="q0" value="2"></li>
</ul>
<ul>
<li>3</li>
<li><input type="radio" autocomplete="off" name="q0" value="3"></li>
</ul>
<ul>
<li>4</li>
<li><input type="radio" autocomplete="off" name="q0" value="4"></li>
</ul>
<ul>
<li>5</li>
<li><input type="radio" autocomplete="off" name="q0" value="5"></li>
</ul>
</div>
</div>
<div id="two" class="question">
<p>On a scale of 0-5, where 0 is not enjoyed it at all and 5 is enjoyed it a lot:</p>
<p>How much did you enjoy the film/event you watched?</p>
<div class="answer">
<ul>
<li>0</li>
<li><input type="radio" autocomplete="off" name="q1" value="0"></li>
</ul>
<ul>
<li>1</li>
<li><input type="radio" autocomplete="off" name="q1" value="1"></li>
</ul>
<ul>
<li>2</li>
<li><input type="radio" autocomplete="off" name="q1" value="2"></li>
</ul>
<ul>
<li>3</li>
<li><input type="radio" autocomplete="off" name="q1" value="3"></li>
</ul>
<ul>
<li>4</li>
<li><input type="radio" autocomplete="off" name="q1" value="4"></li>
</ul>
<ul>
<li>5</li>
<li><input type="radio" autocomplete="off" name="q1" value="5"></li>
</ul>
</div>
</div>
<div id="three" class="question">
<p>On a scale of 0-5, where 0 is very unhelpful and 5 is very helpful:</p>
<p>Overall, how helpful were the Classic Screenings staff?</p>
<div class="answer">
<ul>
<li>0</li>
<li><input type="radio" autocomplete="off" name="q2" value="0"></li>
</ul>
<ul>
<li>1</li>
<li><input type="radio" autocomplete="off" name="q2" value="1"></li>
</ul>
<ul>
<li>2</li>
<li><input type="radio" autocomplete="off" name="q2" value="2"></li>
</ul>
<ul>
<li>3</li>
<li><input type="radio" autocomplete="off" name="q2" value="3"></li>
</ul>
<ul>
<li>4</li>
<li><input type="radio" autocomplete="off" name="q2" value="4"></li>
</ul>
<ul>
<li>5</li>
<li><input type="radio" autocomplete="off" name="q2" value="5"></li>
</ul>
</div>
</div>
<div id="four" class="question">
<p>Did you purchase any food / snacks from the cinema?</p>
<div class="yesOrNo">
Yes<input class="yorn snacks" autocomplete="off" type="radio" name="food" value="yes">
No<input class="yorn snacks" autocomplete="off" type="radio" name="food" value="no">
</div>
<div id="food-followUp">
<p>On a scale of 0-5, where 0 is very poor and 5 is excellent:</p>
<p>What do you rate the quality of the food / snacks?</p>
<div class="answer">
<ul>
<li>0</li>
<li><input type="radio" autocomplete="off" name="q3" value="0"></li>
</ul>
<ul>
<li>1</li>
<li><input type="radio" autocomplete="off" name="q3" value="1"></li>
</ul>
<ul>
<li>2</li>
<li><input type="radio" autocomplete="off" name="q3" value="2"></li>
</ul>
<ul>
<li>3</li>
<li><input type="radio" autocomplete="off" name="q3" value="3"></li>
</ul>
<ul>
<li>4</li>
<li><input type="radio" autocomplete="off" name="q3" value="4"></li>
</ul>
<ul>
<li>5</li>
<li><input type="radio" autocomplete="off" name="q3" value="5"></li>
</ul>
</div>
</div>
</div>
<div id="five" class="question">
<p>Did you visit the toilet facilities during your visit to Clasic Screenins Cinema?</p>
<div class="yesOrNo">
Yes<input class="yorn facilities" autocomplete="off" type="radio" name="yorn" value="yes">
No<input class="yorn facilities" autocomplete="off" type="radio" name="yorn" value="no">
</div>
<div id="facilities-followUp">
<p>On a scale of 0-5, where 0 is extremely dissatisfied and 5 is extremely satisfied, how would you rate the following:?</p>
<p>Cleanliness of the toilet facilities</p>
<div class="answer">
<ul>
<li>0</li>
<li><input type="radio" autocomplete="off" name="q4" value="0"></li>
</ul>
<ul>
<li>1</li>
<li><input type="radio" autocomplete="off" name="q4" value="1"></li>
</ul>
<ul>
<li>2</li>
<li><input type="radio" autocomplete="off" name="q4" value="2"></li>
</ul>
<ul>
<li>3</li>
<li><input type="radio" autocomplete="off" name="q4" value="3"></li>
</ul>
<ul>
<li>4</li>
<li><input type="radio" autocomplete="off" name="q4" value="4"></li>
</ul>
<ul>
<li>5</li>
<li><input type="radio" autocomplete="off" name="q4" value="5"></li>
</ul>
</div>
</div>
</div>
<div id="six" class="question">
<p>On a scale of 0-5, where 0 is extremely dissatisfied and 5 is extremely satisfied, how would you rate the following:?</p>
<p>The amount of time it took to purchase your ticket, factoring in any time with queuing?</p>
<div class="answer">
<ul>
<li>0</li>
<li><input type="radio" autocomplete="off" name="q5" value="0"></li>
</ul>
<ul>
<li>1</li>
<li><input type="radio" autocomplete="off" name="q5" value="1"></li>
</ul>
<ul>
<li>2</li>
<li><input type="radio" autocomplete="off" name="q5" value="2"></li>
</ul>
<ul>
<li>3</li>
<li><input type="radio" autocomplete="off" name="q5" value="3"></li>
</ul>
<ul>
<li>4</li>
<li><input type="radio" autocomplete="off" name="q5" value="4"></li>
</ul>
<ul>
<li>5</li>
<li><input type="radio" autocomplete="off" name="q5" value="5"></li>
</ul>
</div>
</div>
<div id="seven" class="question">
<p>With regards to entering the cinema screen and taking your allocated seat, please let us know how strong you agree with the following statements, with 0 representing strongly disagree and 5 representing strongly agree.</p>
<p>My allocated seat was in great condition</p>
<div class="answer">
<ul>
<li>0</li>
<li><input type="radio" autocomplete="off" name="q6" value="0"></li>
</ul>
<ul>
<li>1</li>
<li><input type="radio" autocomplete="off" name="q6" value="1"></li>
</ul>
<ul>
<li>2</li>
<li><input type="radio" autocomplete="off" name="q6" value="2"></li>
</ul>
<ul>
<li>3</li>
<li><input type="radio" autocomplete="off" name="q6" value="3"></li>
</ul>
<ul>
<li>4</li>
<li><input type="radio" autocomplete="off" name="q6" value="4"></li>
</ul>
<ul>
<li>5</li>
<li><input type="radio" autocomplete="off" name="q6" value="5"></li>
</ul>
</div>
<p>The area around my seat was clean and tidy</p>
<div class="answer">
<ul>
<li>0</li>
<li><input type="radio" autocomplete="off" name="q7" value="0"></li>
</ul>
<ul>
<li>1</li>
<li><input type="radio" autocomplete="off" name="q7" value="1"></li>
</ul>
<ul>
<li>2</li>
<li><input type="radio" autocomplete="off" name="q7" value="2"></li>
</ul>
<ul>
<li>3</li>
<li><input type="radio" autocomplete="off" name="q7" value="3"></li>
</ul>
<ul>
<li>4</li>
<li><input type="radio" autocomplete="off" name="q7" value="4"></li>
</ul>
<ul>
<li>5</li>
<li><input type="radio" autocomplete="off" name="q7" value="5"></li>
</ul>
</div>
</div>
<div id="eight" class="question">
<p>Were there any disruptions that occured during the viewing of you movie / event?</p>
<div class="yesOrNo">
Yes<input class="yorn" autocomplete="off" type="radio" name="yorn" value="yes">
No<input class="yorn" autocomplete="off" type="radio" name="yorn" value="no">
</div>
<p class="disrupted">Please tell us more about the disruption and what staff did to handle this</p>
<textarea></textarea>
</div>
<div id="nine" class="question">
<h2>THANK YOU FOR COMPLETING OUR SURVEY!</h2>
<p>We are very grateful towards you taking the time out to complete this survery.</p>
<p>Every couple of months our team reflect on these surverys and we develop straregies on the best ways to deal with areas in which can do with improving, as well as ideas on how to further strengthen the positives.</p>
<p>Once again, we thank you for filling in the survey and we hope to see you soon!</p>
</div>
</div>
<div class="navigate">
<div id="backBtn" class="back questionchoice">
<h2>BACK</h2>
</div>
<div id="nextBtn" class="next questionchoice">
<h2>NEXT</h2>
</div>
</div>
</div>
js:
$(document).ready(function(){
var facilityQ = document.querySelectorAll(".facilities");
var foodChoice = document.querySelectorAll(".snacks");
var backBtn = document.getElementById("backBtn");
var nextBtn = document.getElementById("nextBtn");
var questions = ["one","two","three","four","five","six","seven","eight","nine"];
currentQuestion = 0;
//scrolling to next question
$(nextBtn).click(function(){
currentQuestion++;
if (currentQuestion == questions.length-1){
nextBtn.style.display = "none";
backBtn.style.display = "none";
}
if (currentQuestion >= 1){
backBtn.style.visibility = "visible";
}
if (currentQuestion < questions.length){
document.getElementById(questions[currentQuestion]).style.display = "block";
document.getElementById(questions[currentQuestion-1]).style.display = "none";
}
});
$(foodChoice[0]).click(function(){
$("#food-followUp").slideDown();
})
$(facilityQ[0]).click(function(){
$("#facilities-followUp").slideDown();
})
// scrolling to previous question
$(backBtn).click(function() {
if (currentQuestion > 0) {
document.getElementById(questions[currentQuestion]).style.display = "none";
document.getElementById(questions[currentQuestion - 1]).style.display = "block";
}
currentQuestion--;
if (currentQuestion === 0) {
backBtn.style.visibility = "hidden";
}
});
问题:
我偶然发现了一个问题,在以这种方式进行调查之前我什至没有想到这个问题。我真的很想拥有单页调查功能,但我正在努力想出一种解决方案来检查每个单选按钮问题,以确保用户在单击下一个按钮之前选择了一个问题。
有没有比较有经验的人可以帮助我吗?我一直在尝试寻找一种方法,但每当我认为我找到了一种方法时,就会引发另一个问题。
非常感谢您的时间、帮助和建议!
最佳答案
也许您可以将当前问题编号连接到元素名称,以便您可以检查是否选择了该特定的单选按钮组。
function getCheckedValue( groupName ) {
var radios = document.getElementsByName( groupName );
for( i = 0; i < radios.length; i++ ) {
if( radios[i].checked ) {
return radios[i].value;
}
}
return false;
}
if ( getCheckedValue( "q" + currentQuestion ) ) {
// there is a radio button selected, proceed
} else {
// ask the user to select a radio button
}
(如何检查单选按钮是否已选中,来自此处 In JavaScript, how can I get all radio buttons in the page with a given name? )
希望对你有帮助
关于javascript - 当用户点击下一页时,不确定如何动态检查所有位于一页的单选按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49432861/
我正在使用 Selenium Web 驱动程序 3.0,并且想要从打开的两个对话框(一个在后台,第二个在前台)的 Activity 对话框中单击“确定”按钮。如何从 html 下面的父 div 单击前
actions: [ FlatButton( onPressed: () {
我有一个问题有点超出我的范围(我真的很高兴我是 Beta)涉及重复项(所以 GROUP BY, HAVING, COUNT),通过将解决方案保留在 SQLite 附带的标准函数中而变得更加复杂。我正在
使用DBI是否可以确定SELECT语句的已执行语句句柄是否返回任何行而不从中获取行? IE。就像是: use DBI; ... my $sth = $dbh->prepare("SELECT ..."
是否可以为“确定”和“关闭”按钮指定回调函数? 如果是JQuery Modal,则可以在初始化时使用按钮字典指定回调函数。 Semantic-ui模态是否提供类似的功能?按下确定后,我该如何寻求其他逻
我想阅读警报中的消息。 示例:如果警报显示“错误的电子邮件地址”。怎么读呢?意味着我想将该消息存储在字符串中。 如何在“警报”中单击“确定”...?? 如何使用 Selenium 来做到这一点? 最佳
我有一个删除按钮: 我试图首先查明是否已选择一个网站,如果已选择一个网站,我需要确定是否已选择一个或多个列表项,如果是,则继续删除这些项目。 我的 if 语句不断返回“您必须首先选择您的列表”,即使它
部分出于好奇——我们想知道在我们的应用程序中发生了什么——部分是因为我们需要在我们的代码中找到一些潜在的问题,我喜欢在我们的网络应用程序运行时跟踪一些一般值。这尤其包括某些对象图的分配内存。 我们的应
我将 SweetAlert 与 Symfony 结合使用,我希望用户在完成删除操作之前进行确认。 发生的情况是,当用户单击删除按钮时,SweetAlert 会弹出,然后立即消失,并且该项目被删除。 在
我们有一个应用程序可以生成不包括字母 O 的随机基数 35 [0-9A-Z]。我正在寻找一种解决方案来查找包含任何淫秽英语单词的代码,而无需搜索包含 10,000 个条目的列表每个生成的代码。每秒生成
这是我做的: #include #include int betweenArray(int a, int b){ int *arr,i,range; range = b - a +
我知道如何创建 警报和确认框,但我不知道如何做的是实际单击“确定”。我有一个弹出确认框的页面。 我想使用 Java Script 插件单击“确定”。基本上,我希望我的代码单击页面上的链接,然后在出现提
代码: swal('Your ORDER has been placed Successfully!!!'); window.location="index.php"; 甜蜜警报工
>>> import re >>> s = "These are the words in a sentence" >>> regex = re.compile('are|words') >>> [m
使用确定的理想散列函数给出随机期望线性时间算法两个数组 A[1..n] 和 B[1..n] 是否不相交,即 A 的元素是否也是 B 的元素。 谁能告诉我如何做到这一点,甚至如何开始考虑它? 最佳答案
我在计算机科学课上有这段代码: int input=15; while (input < n ) { input = input *3;} 这段代码有 log3(n/15) 次循环的上限。我们怎样才能
我有一个允许 2 位玩家玩 TicTacToe 的程序。在每个玩家移动之后,它应该在那个点显示棋盘并返回一个名为 Status 的枚举,显示玩家是否应该继续,如果玩家赢了,还是平局。但是,该算法要么返
给定一个 y 值数组,例如 [-3400, -1000, 500, 1200, 3790],我如何确定“好的”Y 轴标签并将它们放置在网格上? ^ ---(6,000)-|---
假设我有一个检查用户登录的 SQL 语句: SELECT * FROM users WHERE username='test@example.com', password='abc123', expi
teradata中有返回表中哪一列被定义为主索引的命令吗?我没有制作一些我正在处理的表,也没有尝试优化我对这些表的连接。谢谢! 最佳答案 有dbc.IndicesV,其中IndexNumber=1表示
我是一名优秀的程序员,十分优秀!