Issues

3.01K viewsIssuesvotersystem
0

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>

Answered question
0

In BitLife, development does not occur abruptly but is built stage by stage. Players can track their progress through various stats and milestones, thereby clearly perceiving the changes their character undergoes.

Answered question
0

Even though your buttons use type="button", the page can still reload if your upVote() / downVote() functions trigger a form submission or don’t prevent default behavior. Inside those JS functions, make sure you call event.preventDefault() or return false to stop the reload.

Alternatively, handle the voting via AJAX (fetch/XHR) so the count updates dynamically without submitting the form at all.

Answered question
0

One of the most addictive aspects of Geometry Dash is its ability to turn frustration into motivation, encouraging players to keep trying until they finally succeed.

Answered question
0

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.

Answered question
0

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.

Answered question