How to add points that add up and are display in the page for the student to see how the points are growing
I am working in a quiz, it has a dropdown with all the posible answer and a query that give one question at the time and contain the right answer, when they are equal I want the quiz to give 3 points. and I want those 3 points to be shown in the top corner of the page and when the student answer the next question and it is correct I want 3 more points to be added and the new total to be shown in the top corner. I was able to get an alert to tell that the answer was correct and to give an alert that I earn 3 points. But what I really want is to see the points been added and display as they grow with each correct answer not alerts although it was a good start because at least now I know that the query and the dropdown are communicating. I also try echo to see if it's display at least the 3 points but I think that echo don't work with JavaScript function. Thanks in advance for your help, have a great day!
<!-- Select page, A dropdown -->
<select id="author">
<option value="">Select Author</option>
<?php
if($rowCount > 0){
while($row = $query->fetch_assoc()){
echo '<option value="'.$row['authors_id'].'">'.$row['authors'].'</option>';
}
}else{
echo '<option value="">Author not available</option>';
}
?>
</select>
<!-- functionpage-->
$(function() {
$('#author').on('change', function(event) {
var opt = this.options[ this.selectedIndex ];
var correct = $(opt).text().match (arr2);
var score = 0;
if (correct){
alert('Good job ' + arr2,);
score++;
alert (score++);
}
else {
echo ('nice try ' + arr2);
}
});
});
</script>
<script>
var arr2=;
arr2.push('<?php
$query = "Select * from Titles"
$res6 = mysqli_query($db,$query) or die(mysqli_error($db));
while($data = mysqli_fetch_array($res6))
{
echo $data['authors'];
}
?>');
</script>
javascript php jquery html mysql
add a comment |
I am working in a quiz, it has a dropdown with all the posible answer and a query that give one question at the time and contain the right answer, when they are equal I want the quiz to give 3 points. and I want those 3 points to be shown in the top corner of the page and when the student answer the next question and it is correct I want 3 more points to be added and the new total to be shown in the top corner. I was able to get an alert to tell that the answer was correct and to give an alert that I earn 3 points. But what I really want is to see the points been added and display as they grow with each correct answer not alerts although it was a good start because at least now I know that the query and the dropdown are communicating. I also try echo to see if it's display at least the 3 points but I think that echo don't work with JavaScript function. Thanks in advance for your help, have a great day!
<!-- Select page, A dropdown -->
<select id="author">
<option value="">Select Author</option>
<?php
if($rowCount > 0){
while($row = $query->fetch_assoc()){
echo '<option value="'.$row['authors_id'].'">'.$row['authors'].'</option>';
}
}else{
echo '<option value="">Author not available</option>';
}
?>
</select>
<!-- functionpage-->
$(function() {
$('#author').on('change', function(event) {
var opt = this.options[ this.selectedIndex ];
var correct = $(opt).text().match (arr2);
var score = 0;
if (correct){
alert('Good job ' + arr2,);
score++;
alert (score++);
}
else {
echo ('nice try ' + arr2);
}
});
});
</script>
<script>
var arr2=;
arr2.push('<?php
$query = "Select * from Titles"
$res6 = mysqli_query($db,$query) or die(mysqli_error($db));
while($data = mysqli_fetch_array($res6))
{
echo $data['authors'];
}
?>');
</script>
javascript php jquery html mysql
Hi Sir, it is hard to help you, using you code example. Please create new jsfiddle with dummy/rendered data with your issue and I will help you in few minutes.
– dganenco
Nov 18 '18 at 17:49
I don't see questions in your code, only a select list with authors.correct
is the result of a call tomatch
, but you pass it an array, whilematch
expects a regular expression as argument.
– trincot
Nov 18 '18 at 21:19
Trincot they are not really questions, one query will show the title of the book and with the dropdown you have to select the author. When they match because in the database every record has a title and an author the I want the program to give 2 points and displayed it. Then if the next one is right add 2 mor points etc
– Elvis Cruz
Nov 18 '18 at 21:43
I could put an alert that alert me when is right or wrong but I want points and display them. And they have to add up with every correct answer. The titles are shown one by one using pagination
– Elvis Cruz
Nov 18 '18 at 21:47
The correct and the match are working fine, I just need to see how I can add a variable outside that can sums up the scores points per page (it is a pagination setup with a limit of 1 at the time from MySQL) and display the current total score.
– Elvis Cruz
Nov 19 '18 at 16:42
add a comment |
I am working in a quiz, it has a dropdown with all the posible answer and a query that give one question at the time and contain the right answer, when they are equal I want the quiz to give 3 points. and I want those 3 points to be shown in the top corner of the page and when the student answer the next question and it is correct I want 3 more points to be added and the new total to be shown in the top corner. I was able to get an alert to tell that the answer was correct and to give an alert that I earn 3 points. But what I really want is to see the points been added and display as they grow with each correct answer not alerts although it was a good start because at least now I know that the query and the dropdown are communicating. I also try echo to see if it's display at least the 3 points but I think that echo don't work with JavaScript function. Thanks in advance for your help, have a great day!
<!-- Select page, A dropdown -->
<select id="author">
<option value="">Select Author</option>
<?php
if($rowCount > 0){
while($row = $query->fetch_assoc()){
echo '<option value="'.$row['authors_id'].'">'.$row['authors'].'</option>';
}
}else{
echo '<option value="">Author not available</option>';
}
?>
</select>
<!-- functionpage-->
$(function() {
$('#author').on('change', function(event) {
var opt = this.options[ this.selectedIndex ];
var correct = $(opt).text().match (arr2);
var score = 0;
if (correct){
alert('Good job ' + arr2,);
score++;
alert (score++);
}
else {
echo ('nice try ' + arr2);
}
});
});
</script>
<script>
var arr2=;
arr2.push('<?php
$query = "Select * from Titles"
$res6 = mysqli_query($db,$query) or die(mysqli_error($db));
while($data = mysqli_fetch_array($res6))
{
echo $data['authors'];
}
?>');
</script>
javascript php jquery html mysql
I am working in a quiz, it has a dropdown with all the posible answer and a query that give one question at the time and contain the right answer, when they are equal I want the quiz to give 3 points. and I want those 3 points to be shown in the top corner of the page and when the student answer the next question and it is correct I want 3 more points to be added and the new total to be shown in the top corner. I was able to get an alert to tell that the answer was correct and to give an alert that I earn 3 points. But what I really want is to see the points been added and display as they grow with each correct answer not alerts although it was a good start because at least now I know that the query and the dropdown are communicating. I also try echo to see if it's display at least the 3 points but I think that echo don't work with JavaScript function. Thanks in advance for your help, have a great day!
<!-- Select page, A dropdown -->
<select id="author">
<option value="">Select Author</option>
<?php
if($rowCount > 0){
while($row = $query->fetch_assoc()){
echo '<option value="'.$row['authors_id'].'">'.$row['authors'].'</option>';
}
}else{
echo '<option value="">Author not available</option>';
}
?>
</select>
<!-- functionpage-->
$(function() {
$('#author').on('change', function(event) {
var opt = this.options[ this.selectedIndex ];
var correct = $(opt).text().match (arr2);
var score = 0;
if (correct){
alert('Good job ' + arr2,);
score++;
alert (score++);
}
else {
echo ('nice try ' + arr2);
}
});
});
</script>
<script>
var arr2=;
arr2.push('<?php
$query = "Select * from Titles"
$res6 = mysqli_query($db,$query) or die(mysqli_error($db));
while($data = mysqli_fetch_array($res6))
{
echo $data['authors'];
}
?>');
</script>
javascript php jquery html mysql
javascript php jquery html mysql
edited Nov 19 '18 at 16:36
Elvis Cruz
asked Nov 18 '18 at 13:00
Elvis CruzElvis Cruz
186
186
Hi Sir, it is hard to help you, using you code example. Please create new jsfiddle with dummy/rendered data with your issue and I will help you in few minutes.
– dganenco
Nov 18 '18 at 17:49
I don't see questions in your code, only a select list with authors.correct
is the result of a call tomatch
, but you pass it an array, whilematch
expects a regular expression as argument.
– trincot
Nov 18 '18 at 21:19
Trincot they are not really questions, one query will show the title of the book and with the dropdown you have to select the author. When they match because in the database every record has a title and an author the I want the program to give 2 points and displayed it. Then if the next one is right add 2 mor points etc
– Elvis Cruz
Nov 18 '18 at 21:43
I could put an alert that alert me when is right or wrong but I want points and display them. And they have to add up with every correct answer. The titles are shown one by one using pagination
– Elvis Cruz
Nov 18 '18 at 21:47
The correct and the match are working fine, I just need to see how I can add a variable outside that can sums up the scores points per page (it is a pagination setup with a limit of 1 at the time from MySQL) and display the current total score.
– Elvis Cruz
Nov 19 '18 at 16:42
add a comment |
Hi Sir, it is hard to help you, using you code example. Please create new jsfiddle with dummy/rendered data with your issue and I will help you in few minutes.
– dganenco
Nov 18 '18 at 17:49
I don't see questions in your code, only a select list with authors.correct
is the result of a call tomatch
, but you pass it an array, whilematch
expects a regular expression as argument.
– trincot
Nov 18 '18 at 21:19
Trincot they are not really questions, one query will show the title of the book and with the dropdown you have to select the author. When they match because in the database every record has a title and an author the I want the program to give 2 points and displayed it. Then if the next one is right add 2 mor points etc
– Elvis Cruz
Nov 18 '18 at 21:43
I could put an alert that alert me when is right or wrong but I want points and display them. And they have to add up with every correct answer. The titles are shown one by one using pagination
– Elvis Cruz
Nov 18 '18 at 21:47
The correct and the match are working fine, I just need to see how I can add a variable outside that can sums up the scores points per page (it is a pagination setup with a limit of 1 at the time from MySQL) and display the current total score.
– Elvis Cruz
Nov 19 '18 at 16:42
Hi Sir, it is hard to help you, using you code example. Please create new jsfiddle with dummy/rendered data with your issue and I will help you in few minutes.
– dganenco
Nov 18 '18 at 17:49
Hi Sir, it is hard to help you, using you code example. Please create new jsfiddle with dummy/rendered data with your issue and I will help you in few minutes.
– dganenco
Nov 18 '18 at 17:49
I don't see questions in your code, only a select list with authors.
correct
is the result of a call to match
, but you pass it an array, while match
expects a regular expression as argument.– trincot
Nov 18 '18 at 21:19
I don't see questions in your code, only a select list with authors.
correct
is the result of a call to match
, but you pass it an array, while match
expects a regular expression as argument.– trincot
Nov 18 '18 at 21:19
Trincot they are not really questions, one query will show the title of the book and with the dropdown you have to select the author. When they match because in the database every record has a title and an author the I want the program to give 2 points and displayed it. Then if the next one is right add 2 mor points etc
– Elvis Cruz
Nov 18 '18 at 21:43
Trincot they are not really questions, one query will show the title of the book and with the dropdown you have to select the author. When they match because in the database every record has a title and an author the I want the program to give 2 points and displayed it. Then if the next one is right add 2 mor points etc
– Elvis Cruz
Nov 18 '18 at 21:43
I could put an alert that alert me when is right or wrong but I want points and display them. And they have to add up with every correct answer. The titles are shown one by one using pagination
– Elvis Cruz
Nov 18 '18 at 21:47
I could put an alert that alert me when is right or wrong but I want points and display them. And they have to add up with every correct answer. The titles are shown one by one using pagination
– Elvis Cruz
Nov 18 '18 at 21:47
The correct and the match are working fine, I just need to see how I can add a variable outside that can sums up the scores points per page (it is a pagination setup with a limit of 1 at the time from MySQL) and display the current total score.
– Elvis Cruz
Nov 19 '18 at 16:42
The correct and the match are working fine, I just need to see how I can add a variable outside that can sums up the scores points per page (it is a pagination setup with a limit of 1 at the time from MySQL) and display the current total score.
– Elvis Cruz
Nov 19 '18 at 16:42
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53361131%2fhow-to-add-points-that-add-up-and-are-display-in-the-page-for-the-student-to-see%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53361131%2fhow-to-add-points-that-add-up-and-are-display-in-the-page-for-the-student-to-see%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Hi Sir, it is hard to help you, using you code example. Please create new jsfiddle with dummy/rendered data with your issue and I will help you in few minutes.
– dganenco
Nov 18 '18 at 17:49
I don't see questions in your code, only a select list with authors.
correct
is the result of a call tomatch
, but you pass it an array, whilematch
expects a regular expression as argument.– trincot
Nov 18 '18 at 21:19
Trincot they are not really questions, one query will show the title of the book and with the dropdown you have to select the author. When they match because in the database every record has a title and an author the I want the program to give 2 points and displayed it. Then if the next one is right add 2 mor points etc
– Elvis Cruz
Nov 18 '18 at 21:43
I could put an alert that alert me when is right or wrong but I want points and display them. And they have to add up with every correct answer. The titles are shown one by one using pagination
– Elvis Cruz
Nov 18 '18 at 21:47
The correct and the match are working fine, I just need to see how I can add a variable outside that can sums up the scores points per page (it is a pagination setup with a limit of 1 at the time from MySQL) and display the current total score.
– Elvis Cruz
Nov 19 '18 at 16:42