window.location.href doesn't submit form [duplicate]











up vote
-1
down vote

favorite













This question already has an answer here:




  • JavaScript post request like a form submit

    28 answers



  • How to submit a form using javascript?

    10 answers




I used the Javascript below.
If the time is finished it must redirect to the next page "result.php" by submitting a form. But unfortunately the page displayed is empty.
below my form which must send to the next page "result.php".
I want to have how to send this form and redirect to the next page.
how to send the form with this Javascript to make my page work?






var hoursleft = 3;
var minutesleft = 0;
var secondsleft = 0;

var end1;
var progressBar = document.getElementById('progressBar');
if (localStorage.getItem("end1")) {
end1 = new Date(localStorage.getItem("end1"));
} else {
end1 = new Date();
end1.setMinutes(end1.getMinutes() + minutesleft);
end1.setSeconds(end1.getSeconds() + secondsleft);
end1.setHours(end1.getHours() + hoursleft);
}
progressBar.max = end1 - new Date();

var counter = function() {
var now = new Date();
var diff = end1 - now;
diff = new Date(diff);
var sec = parseInt((diff / 1000) % 60)
var mins = parseInt((diff / (1000 * 60)) % 60)
var hours = parseInt((diff / (1000 * 60 * 60)) % 24);
if (hours < 10) {
hours = "0" + hours;
}
if (mins < 10) {
mins = "0" + mins;
}
if (sec < 10) {
sec = "0" + sec;
}
if (now >= end1) {
clearTimeout(interval);
localStorage.setItem("end", null);
localStorage.removeItem("end1");
localStorage.clear();

if (confirm("TIME UP!"))
window.location.href = "result.php";
//alert("Time finished!");

} else {
progressBar.value = progressBar.max - (end1 - now);
localStorage.setItem("end1", end1);
document.getElementById('hours').innerHTML = "<b>" + hours + "</b>&nbsp;&nbsp;&nbsp;" + ":";
document.getElementById('mins').innerHTML = "<b>" + mins + "</b>&nbsp;&nbsp;&nbsp;" + ":";
document.getElementById('sec').innerHTML = "<b>" + sec + "</b>";
}
}
var interval = setInterval(counter, 1000);

	<form class="form-horizontal" role="form" id='question' name="question" method="post"  action="result.php">

<?php
$number_question=1;
$limit=10;
$row = mysqli_query( $conn, "select id,question_name,image from testquestion where email = '".$email."' ");
$total = mysqli_num_rows( $row );
$remainder = $total/$number_question;
$i = 0;
$j = 1; $k = 1;
?>
<?php while ( $result = mysqli_fetch_assoc($row) ) {
if ( $i != 0)
echo "<div id='question_splitter_$j'>";
if ( $i == 0)
echo "<div class='cont' id='question_splitter_$j'>";?>
<div id='question<?php echo $k;?>' >
<p class='questions' id="qname<?php echo $j;?>"> <?php echo $k?>.<?php echo $result['question_name'];?>
<input type="checkbox" id="review" name="review" />
<label style="color:#0080ff">Review</label></p>

</br>
<?php echo '<img src="data:image/png;base64,'.($result['image']).'" />'; ?></br><br/><br/>
<input type="text" id="answer<?php echo $result['id'];?>" name="<?php echo $result['id'];?>" placeholder="Enter your answer" />
<br/>
<br/>
</div>
<?php
$i++;
if ( ( $remainder < 1 ) || ( $i == $number_question && $remainder == 1 ) ) {
echo "<button id='".$j."' class='next btn btn-primary' type='submit'>Finish</button>";
echo "</div>";
} elseif ( $total > $number_question ) {
if ( $j == 1 && $i == $number_question ) {
echo "<button id='".$j."' class='next btn btn-primary' type='button'>Next</button>";
echo "</div>";
$i = 0;
$j++;
} elseif ( $k == $total ) {
echo " <button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<a href='review.php'><button id='review.php' class='previous btn btn-primary' type='button'>Review</button></a>
<button id='".$j."' class='next btn btn-primary' type='submit'>Finish</button>";
echo "</div>";
$i = 0;
$j++;
} elseif ( $j > 1 && $i == $number_question ) {
echo "<button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<button id='".$j."' class='next btn btn-primary' type='button' >Next</button>";
echo "</div>";
$i = 0;
$j++;
}
}
$k++;
}

?>
<br/>
<br/>
<br/>
</form>












share|improve this question















marked as duplicate by Tigger, Davіd, Quentin html
Users with the  html badge can single-handedly close html questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
2 hours ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    Use $("#question").submit(); in place of window.location.href = "result.php";
    – Twinkle
    2 hours ago












  • It works Thank you very much.
    – sonia
    2 hours ago















up vote
-1
down vote

favorite













This question already has an answer here:




  • JavaScript post request like a form submit

    28 answers



  • How to submit a form using javascript?

    10 answers




I used the Javascript below.
If the time is finished it must redirect to the next page "result.php" by submitting a form. But unfortunately the page displayed is empty.
below my form which must send to the next page "result.php".
I want to have how to send this form and redirect to the next page.
how to send the form with this Javascript to make my page work?






var hoursleft = 3;
var minutesleft = 0;
var secondsleft = 0;

var end1;
var progressBar = document.getElementById('progressBar');
if (localStorage.getItem("end1")) {
end1 = new Date(localStorage.getItem("end1"));
} else {
end1 = new Date();
end1.setMinutes(end1.getMinutes() + minutesleft);
end1.setSeconds(end1.getSeconds() + secondsleft);
end1.setHours(end1.getHours() + hoursleft);
}
progressBar.max = end1 - new Date();

var counter = function() {
var now = new Date();
var diff = end1 - now;
diff = new Date(diff);
var sec = parseInt((diff / 1000) % 60)
var mins = parseInt((diff / (1000 * 60)) % 60)
var hours = parseInt((diff / (1000 * 60 * 60)) % 24);
if (hours < 10) {
hours = "0" + hours;
}
if (mins < 10) {
mins = "0" + mins;
}
if (sec < 10) {
sec = "0" + sec;
}
if (now >= end1) {
clearTimeout(interval);
localStorage.setItem("end", null);
localStorage.removeItem("end1");
localStorage.clear();

if (confirm("TIME UP!"))
window.location.href = "result.php";
//alert("Time finished!");

} else {
progressBar.value = progressBar.max - (end1 - now);
localStorage.setItem("end1", end1);
document.getElementById('hours').innerHTML = "<b>" + hours + "</b>&nbsp;&nbsp;&nbsp;" + ":";
document.getElementById('mins').innerHTML = "<b>" + mins + "</b>&nbsp;&nbsp;&nbsp;" + ":";
document.getElementById('sec').innerHTML = "<b>" + sec + "</b>";
}
}
var interval = setInterval(counter, 1000);

	<form class="form-horizontal" role="form" id='question' name="question" method="post"  action="result.php">

<?php
$number_question=1;
$limit=10;
$row = mysqli_query( $conn, "select id,question_name,image from testquestion where email = '".$email."' ");
$total = mysqli_num_rows( $row );
$remainder = $total/$number_question;
$i = 0;
$j = 1; $k = 1;
?>
<?php while ( $result = mysqli_fetch_assoc($row) ) {
if ( $i != 0)
echo "<div id='question_splitter_$j'>";
if ( $i == 0)
echo "<div class='cont' id='question_splitter_$j'>";?>
<div id='question<?php echo $k;?>' >
<p class='questions' id="qname<?php echo $j;?>"> <?php echo $k?>.<?php echo $result['question_name'];?>
<input type="checkbox" id="review" name="review" />
<label style="color:#0080ff">Review</label></p>

</br>
<?php echo '<img src="data:image/png;base64,'.($result['image']).'" />'; ?></br><br/><br/>
<input type="text" id="answer<?php echo $result['id'];?>" name="<?php echo $result['id'];?>" placeholder="Enter your answer" />
<br/>
<br/>
</div>
<?php
$i++;
if ( ( $remainder < 1 ) || ( $i == $number_question && $remainder == 1 ) ) {
echo "<button id='".$j."' class='next btn btn-primary' type='submit'>Finish</button>";
echo "</div>";
} elseif ( $total > $number_question ) {
if ( $j == 1 && $i == $number_question ) {
echo "<button id='".$j."' class='next btn btn-primary' type='button'>Next</button>";
echo "</div>";
$i = 0;
$j++;
} elseif ( $k == $total ) {
echo " <button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<a href='review.php'><button id='review.php' class='previous btn btn-primary' type='button'>Review</button></a>
<button id='".$j."' class='next btn btn-primary' type='submit'>Finish</button>";
echo "</div>";
$i = 0;
$j++;
} elseif ( $j > 1 && $i == $number_question ) {
echo "<button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<button id='".$j."' class='next btn btn-primary' type='button' >Next</button>";
echo "</div>";
$i = 0;
$j++;
}
}
$k++;
}

?>
<br/>
<br/>
<br/>
</form>












share|improve this question















marked as duplicate by Tigger, Davіd, Quentin html
Users with the  html badge can single-handedly close html questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
2 hours ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    Use $("#question").submit(); in place of window.location.href = "result.php";
    – Twinkle
    2 hours ago












  • It works Thank you very much.
    – sonia
    2 hours ago













up vote
-1
down vote

favorite









up vote
-1
down vote

favorite












This question already has an answer here:




  • JavaScript post request like a form submit

    28 answers



  • How to submit a form using javascript?

    10 answers




I used the Javascript below.
If the time is finished it must redirect to the next page "result.php" by submitting a form. But unfortunately the page displayed is empty.
below my form which must send to the next page "result.php".
I want to have how to send this form and redirect to the next page.
how to send the form with this Javascript to make my page work?






var hoursleft = 3;
var minutesleft = 0;
var secondsleft = 0;

var end1;
var progressBar = document.getElementById('progressBar');
if (localStorage.getItem("end1")) {
end1 = new Date(localStorage.getItem("end1"));
} else {
end1 = new Date();
end1.setMinutes(end1.getMinutes() + minutesleft);
end1.setSeconds(end1.getSeconds() + secondsleft);
end1.setHours(end1.getHours() + hoursleft);
}
progressBar.max = end1 - new Date();

var counter = function() {
var now = new Date();
var diff = end1 - now;
diff = new Date(diff);
var sec = parseInt((diff / 1000) % 60)
var mins = parseInt((diff / (1000 * 60)) % 60)
var hours = parseInt((diff / (1000 * 60 * 60)) % 24);
if (hours < 10) {
hours = "0" + hours;
}
if (mins < 10) {
mins = "0" + mins;
}
if (sec < 10) {
sec = "0" + sec;
}
if (now >= end1) {
clearTimeout(interval);
localStorage.setItem("end", null);
localStorage.removeItem("end1");
localStorage.clear();

if (confirm("TIME UP!"))
window.location.href = "result.php";
//alert("Time finished!");

} else {
progressBar.value = progressBar.max - (end1 - now);
localStorage.setItem("end1", end1);
document.getElementById('hours').innerHTML = "<b>" + hours + "</b>&nbsp;&nbsp;&nbsp;" + ":";
document.getElementById('mins').innerHTML = "<b>" + mins + "</b>&nbsp;&nbsp;&nbsp;" + ":";
document.getElementById('sec').innerHTML = "<b>" + sec + "</b>";
}
}
var interval = setInterval(counter, 1000);

	<form class="form-horizontal" role="form" id='question' name="question" method="post"  action="result.php">

<?php
$number_question=1;
$limit=10;
$row = mysqli_query( $conn, "select id,question_name,image from testquestion where email = '".$email."' ");
$total = mysqli_num_rows( $row );
$remainder = $total/$number_question;
$i = 0;
$j = 1; $k = 1;
?>
<?php while ( $result = mysqli_fetch_assoc($row) ) {
if ( $i != 0)
echo "<div id='question_splitter_$j'>";
if ( $i == 0)
echo "<div class='cont' id='question_splitter_$j'>";?>
<div id='question<?php echo $k;?>' >
<p class='questions' id="qname<?php echo $j;?>"> <?php echo $k?>.<?php echo $result['question_name'];?>
<input type="checkbox" id="review" name="review" />
<label style="color:#0080ff">Review</label></p>

</br>
<?php echo '<img src="data:image/png;base64,'.($result['image']).'" />'; ?></br><br/><br/>
<input type="text" id="answer<?php echo $result['id'];?>" name="<?php echo $result['id'];?>" placeholder="Enter your answer" />
<br/>
<br/>
</div>
<?php
$i++;
if ( ( $remainder < 1 ) || ( $i == $number_question && $remainder == 1 ) ) {
echo "<button id='".$j."' class='next btn btn-primary' type='submit'>Finish</button>";
echo "</div>";
} elseif ( $total > $number_question ) {
if ( $j == 1 && $i == $number_question ) {
echo "<button id='".$j."' class='next btn btn-primary' type='button'>Next</button>";
echo "</div>";
$i = 0;
$j++;
} elseif ( $k == $total ) {
echo " <button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<a href='review.php'><button id='review.php' class='previous btn btn-primary' type='button'>Review</button></a>
<button id='".$j."' class='next btn btn-primary' type='submit'>Finish</button>";
echo "</div>";
$i = 0;
$j++;
} elseif ( $j > 1 && $i == $number_question ) {
echo "<button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<button id='".$j."' class='next btn btn-primary' type='button' >Next</button>";
echo "</div>";
$i = 0;
$j++;
}
}
$k++;
}

?>
<br/>
<br/>
<br/>
</form>












share|improve this question
















This question already has an answer here:




  • JavaScript post request like a form submit

    28 answers



  • How to submit a form using javascript?

    10 answers




I used the Javascript below.
If the time is finished it must redirect to the next page "result.php" by submitting a form. But unfortunately the page displayed is empty.
below my form which must send to the next page "result.php".
I want to have how to send this form and redirect to the next page.
how to send the form with this Javascript to make my page work?






var hoursleft = 3;
var minutesleft = 0;
var secondsleft = 0;

var end1;
var progressBar = document.getElementById('progressBar');
if (localStorage.getItem("end1")) {
end1 = new Date(localStorage.getItem("end1"));
} else {
end1 = new Date();
end1.setMinutes(end1.getMinutes() + minutesleft);
end1.setSeconds(end1.getSeconds() + secondsleft);
end1.setHours(end1.getHours() + hoursleft);
}
progressBar.max = end1 - new Date();

var counter = function() {
var now = new Date();
var diff = end1 - now;
diff = new Date(diff);
var sec = parseInt((diff / 1000) % 60)
var mins = parseInt((diff / (1000 * 60)) % 60)
var hours = parseInt((diff / (1000 * 60 * 60)) % 24);
if (hours < 10) {
hours = "0" + hours;
}
if (mins < 10) {
mins = "0" + mins;
}
if (sec < 10) {
sec = "0" + sec;
}
if (now >= end1) {
clearTimeout(interval);
localStorage.setItem("end", null);
localStorage.removeItem("end1");
localStorage.clear();

if (confirm("TIME UP!"))
window.location.href = "result.php";
//alert("Time finished!");

} else {
progressBar.value = progressBar.max - (end1 - now);
localStorage.setItem("end1", end1);
document.getElementById('hours').innerHTML = "<b>" + hours + "</b>&nbsp;&nbsp;&nbsp;" + ":";
document.getElementById('mins').innerHTML = "<b>" + mins + "</b>&nbsp;&nbsp;&nbsp;" + ":";
document.getElementById('sec').innerHTML = "<b>" + sec + "</b>";
}
}
var interval = setInterval(counter, 1000);

	<form class="form-horizontal" role="form" id='question' name="question" method="post"  action="result.php">

<?php
$number_question=1;
$limit=10;
$row = mysqli_query( $conn, "select id,question_name,image from testquestion where email = '".$email."' ");
$total = mysqli_num_rows( $row );
$remainder = $total/$number_question;
$i = 0;
$j = 1; $k = 1;
?>
<?php while ( $result = mysqli_fetch_assoc($row) ) {
if ( $i != 0)
echo "<div id='question_splitter_$j'>";
if ( $i == 0)
echo "<div class='cont' id='question_splitter_$j'>";?>
<div id='question<?php echo $k;?>' >
<p class='questions' id="qname<?php echo $j;?>"> <?php echo $k?>.<?php echo $result['question_name'];?>
<input type="checkbox" id="review" name="review" />
<label style="color:#0080ff">Review</label></p>

</br>
<?php echo '<img src="data:image/png;base64,'.($result['image']).'" />'; ?></br><br/><br/>
<input type="text" id="answer<?php echo $result['id'];?>" name="<?php echo $result['id'];?>" placeholder="Enter your answer" />
<br/>
<br/>
</div>
<?php
$i++;
if ( ( $remainder < 1 ) || ( $i == $number_question && $remainder == 1 ) ) {
echo "<button id='".$j."' class='next btn btn-primary' type='submit'>Finish</button>";
echo "</div>";
} elseif ( $total > $number_question ) {
if ( $j == 1 && $i == $number_question ) {
echo "<button id='".$j."' class='next btn btn-primary' type='button'>Next</button>";
echo "</div>";
$i = 0;
$j++;
} elseif ( $k == $total ) {
echo " <button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<a href='review.php'><button id='review.php' class='previous btn btn-primary' type='button'>Review</button></a>
<button id='".$j."' class='next btn btn-primary' type='submit'>Finish</button>";
echo "</div>";
$i = 0;
$j++;
} elseif ( $j > 1 && $i == $number_question ) {
echo "<button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<button id='".$j."' class='next btn btn-primary' type='button' >Next</button>";
echo "</div>";
$i = 0;
$j++;
}
}
$k++;
}

?>
<br/>
<br/>
<br/>
</form>







This question already has an answer here:




  • JavaScript post request like a form submit

    28 answers



  • How to submit a form using javascript?

    10 answers







var hoursleft = 3;
var minutesleft = 0;
var secondsleft = 0;

var end1;
var progressBar = document.getElementById('progressBar');
if (localStorage.getItem("end1")) {
end1 = new Date(localStorage.getItem("end1"));
} else {
end1 = new Date();
end1.setMinutes(end1.getMinutes() + minutesleft);
end1.setSeconds(end1.getSeconds() + secondsleft);
end1.setHours(end1.getHours() + hoursleft);
}
progressBar.max = end1 - new Date();

var counter = function() {
var now = new Date();
var diff = end1 - now;
diff = new Date(diff);
var sec = parseInt((diff / 1000) % 60)
var mins = parseInt((diff / (1000 * 60)) % 60)
var hours = parseInt((diff / (1000 * 60 * 60)) % 24);
if (hours < 10) {
hours = "0" + hours;
}
if (mins < 10) {
mins = "0" + mins;
}
if (sec < 10) {
sec = "0" + sec;
}
if (now >= end1) {
clearTimeout(interval);
localStorage.setItem("end", null);
localStorage.removeItem("end1");
localStorage.clear();

if (confirm("TIME UP!"))
window.location.href = "result.php";
//alert("Time finished!");

} else {
progressBar.value = progressBar.max - (end1 - now);
localStorage.setItem("end1", end1);
document.getElementById('hours').innerHTML = "<b>" + hours + "</b>&nbsp;&nbsp;&nbsp;" + ":";
document.getElementById('mins').innerHTML = "<b>" + mins + "</b>&nbsp;&nbsp;&nbsp;" + ":";
document.getElementById('sec').innerHTML = "<b>" + sec + "</b>";
}
}
var interval = setInterval(counter, 1000);

	<form class="form-horizontal" role="form" id='question' name="question" method="post"  action="result.php">

<?php
$number_question=1;
$limit=10;
$row = mysqli_query( $conn, "select id,question_name,image from testquestion where email = '".$email."' ");
$total = mysqli_num_rows( $row );
$remainder = $total/$number_question;
$i = 0;
$j = 1; $k = 1;
?>
<?php while ( $result = mysqli_fetch_assoc($row) ) {
if ( $i != 0)
echo "<div id='question_splitter_$j'>";
if ( $i == 0)
echo "<div class='cont' id='question_splitter_$j'>";?>
<div id='question<?php echo $k;?>' >
<p class='questions' id="qname<?php echo $j;?>"> <?php echo $k?>.<?php echo $result['question_name'];?>
<input type="checkbox" id="review" name="review" />
<label style="color:#0080ff">Review</label></p>

</br>
<?php echo '<img src="data:image/png;base64,'.($result['image']).'" />'; ?></br><br/><br/>
<input type="text" id="answer<?php echo $result['id'];?>" name="<?php echo $result['id'];?>" placeholder="Enter your answer" />
<br/>
<br/>
</div>
<?php
$i++;
if ( ( $remainder < 1 ) || ( $i == $number_question && $remainder == 1 ) ) {
echo "<button id='".$j."' class='next btn btn-primary' type='submit'>Finish</button>";
echo "</div>";
} elseif ( $total > $number_question ) {
if ( $j == 1 && $i == $number_question ) {
echo "<button id='".$j."' class='next btn btn-primary' type='button'>Next</button>";
echo "</div>";
$i = 0;
$j++;
} elseif ( $k == $total ) {
echo " <button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<a href='review.php'><button id='review.php' class='previous btn btn-primary' type='button'>Review</button></a>
<button id='".$j."' class='next btn btn-primary' type='submit'>Finish</button>";
echo "</div>";
$i = 0;
$j++;
} elseif ( $j > 1 && $i == $number_question ) {
echo "<button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<button id='".$j."' class='next btn btn-primary' type='button' >Next</button>";
echo "</div>";
$i = 0;
$j++;
}
}
$k++;
}

?>
<br/>
<br/>
<br/>
</form>





var hoursleft = 3;
var minutesleft = 0;
var secondsleft = 0;

var end1;
var progressBar = document.getElementById('progressBar');
if (localStorage.getItem("end1")) {
end1 = new Date(localStorage.getItem("end1"));
} else {
end1 = new Date();
end1.setMinutes(end1.getMinutes() + minutesleft);
end1.setSeconds(end1.getSeconds() + secondsleft);
end1.setHours(end1.getHours() + hoursleft);
}
progressBar.max = end1 - new Date();

var counter = function() {
var now = new Date();
var diff = end1 - now;
diff = new Date(diff);
var sec = parseInt((diff / 1000) % 60)
var mins = parseInt((diff / (1000 * 60)) % 60)
var hours = parseInt((diff / (1000 * 60 * 60)) % 24);
if (hours < 10) {
hours = "0" + hours;
}
if (mins < 10) {
mins = "0" + mins;
}
if (sec < 10) {
sec = "0" + sec;
}
if (now >= end1) {
clearTimeout(interval);
localStorage.setItem("end", null);
localStorage.removeItem("end1");
localStorage.clear();

if (confirm("TIME UP!"))
window.location.href = "result.php";
//alert("Time finished!");

} else {
progressBar.value = progressBar.max - (end1 - now);
localStorage.setItem("end1", end1);
document.getElementById('hours').innerHTML = "<b>" + hours + "</b>&nbsp;&nbsp;&nbsp;" + ":";
document.getElementById('mins').innerHTML = "<b>" + mins + "</b>&nbsp;&nbsp;&nbsp;" + ":";
document.getElementById('sec').innerHTML = "<b>" + sec + "</b>";
}
}
var interval = setInterval(counter, 1000);

	<form class="form-horizontal" role="form" id='question' name="question" method="post"  action="result.php">

<?php
$number_question=1;
$limit=10;
$row = mysqli_query( $conn, "select id,question_name,image from testquestion where email = '".$email."' ");
$total = mysqli_num_rows( $row );
$remainder = $total/$number_question;
$i = 0;
$j = 1; $k = 1;
?>
<?php while ( $result = mysqli_fetch_assoc($row) ) {
if ( $i != 0)
echo "<div id='question_splitter_$j'>";
if ( $i == 0)
echo "<div class='cont' id='question_splitter_$j'>";?>
<div id='question<?php echo $k;?>' >
<p class='questions' id="qname<?php echo $j;?>"> <?php echo $k?>.<?php echo $result['question_name'];?>
<input type="checkbox" id="review" name="review" />
<label style="color:#0080ff">Review</label></p>

</br>
<?php echo '<img src="data:image/png;base64,'.($result['image']).'" />'; ?></br><br/><br/>
<input type="text" id="answer<?php echo $result['id'];?>" name="<?php echo $result['id'];?>" placeholder="Enter your answer" />
<br/>
<br/>
</div>
<?php
$i++;
if ( ( $remainder < 1 ) || ( $i == $number_question && $remainder == 1 ) ) {
echo "<button id='".$j."' class='next btn btn-primary' type='submit'>Finish</button>";
echo "</div>";
} elseif ( $total > $number_question ) {
if ( $j == 1 && $i == $number_question ) {
echo "<button id='".$j."' class='next btn btn-primary' type='button'>Next</button>";
echo "</div>";
$i = 0;
$j++;
} elseif ( $k == $total ) {
echo " <button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<a href='review.php'><button id='review.php' class='previous btn btn-primary' type='button'>Review</button></a>
<button id='".$j."' class='next btn btn-primary' type='submit'>Finish</button>";
echo "</div>";
$i = 0;
$j++;
} elseif ( $j > 1 && $i == $number_question ) {
echo "<button id='".$j."' class='previous btn btn-primary' type='button'>Previous</button>
<button id='".$j."' class='next btn btn-primary' type='button' >Next</button>";
echo "</div>";
$i = 0;
$j++;
}
}
$k++;
}

?>
<br/>
<br/>
<br/>
</form>






javascript php html






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 hours ago

























asked 2 hours ago









sonia

73




73




marked as duplicate by Tigger, Davіd, Quentin html
Users with the  html badge can single-handedly close html questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
2 hours ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Tigger, Davіd, Quentin html
Users with the  html badge can single-handedly close html questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
2 hours ago


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    Use $("#question").submit(); in place of window.location.href = "result.php";
    – Twinkle
    2 hours ago












  • It works Thank you very much.
    – sonia
    2 hours ago














  • 1




    Use $("#question").submit(); in place of window.location.href = "result.php";
    – Twinkle
    2 hours ago












  • It works Thank you very much.
    – sonia
    2 hours ago








1




1




Use $("#question").submit(); in place of window.location.href = "result.php";
– Twinkle
2 hours ago






Use $("#question").submit(); in place of window.location.href = "result.php";
– Twinkle
2 hours ago














It works Thank you very much.
– sonia
2 hours ago




It works Thank you very much.
– sonia
2 hours ago












1 Answer
1






active

oldest

votes

















up vote
0
down vote













You have to use document.getElementById('question').submit(); with window.location.href = "result.php"; the POST data isnt posted






share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    You have to use document.getElementById('question').submit(); with window.location.href = "result.php"; the POST data isnt posted






    share|improve this answer

























      up vote
      0
      down vote













      You have to use document.getElementById('question').submit(); with window.location.href = "result.php"; the POST data isnt posted






      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        You have to use document.getElementById('question').submit(); with window.location.href = "result.php"; the POST data isnt posted






        share|improve this answer












        You have to use document.getElementById('question').submit(); with window.location.href = "result.php"; the POST data isnt posted







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 2 hours ago









        Rick Grendel

        42118




        42118















            Popular posts from this blog

            A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

            Calculate evaluation metrics using cross_val_predict sklearn

            Insert data from modal to MySQL (multiple modal on website)