Issues
On the voter system, the selected
button up down usually reloads to count. How can that be stopped?
<form method=”post” id=”voteform” action=””>
<button type=”button” class=”btn btn-light” name=”up” title=”Vote Up ” style=”padding: .5vh 1vh; margin-top:3px;” onclick= <?php if ( is_user_logged_in()) { ?>
“upVote(<?php echo $answeridx; ?>)”<?php } else {?>
“window.location.href = ‘/wp-login.php’;” <?php } ?>
value =”<?php echo $answeridx; ?>”><i class=”fa-solid fa-thumbs-up”></i><div id=”up_count<?php echo $answeridx; ?>” class=”label-vote”><?php echo $var=0+$thumbsup; ?></div></button>
<div class=”label-vote”><?php //echo $thumbsup; ?></div>
<button type=”button” class=”btn btn-light” name=”down” title=”Vote down” class=”btn btn-light” style=”padding: .5vh 1vh; margin-top:3px;” onclick=<?php if ( is_user_logged_in()) { ?>
“downVote(<?php echo $answeridx; ?>)”<?php } else {?>
“window.location.href = ‘/wp-login.php’;” <?php } ?> value =”<?php echo $answeridx; ?>” >
<i class=”fa-solid fa-thumbs-down”></i><div id=”down_count<?php echo $answeridx; ?>” class=”label-vote”><?php echo $var=0+$thumbsdown; ?></div></button>
</form>
The term unblocked games didn’t appear in any official tech manual or gaming journal. It was born in classrooms, whispered among students, scribbled on notebook covers, and typed into search bars during free periods.
The page reloads because the buttons are inside a `<form>` tag, and even with `type=”button”`, some browsers may still try to submit the form. To prevent this, you should use choiceadvantage com JavaScript’s `event.preventDefault()` method. Modify your `onclick` functions to accept an `event` object and call `event.preventDefault()` at the beginning of the function. This will stop the default page reload behavior and allow your vote counting logic to work without interruption, a common practice for implementing features with AJAX.