Duplicate Error Messages [RESOLVED]
Posted: Sat Sep 27, 2014 10:26 pm
Hey all, I'm using Javascript to display error messages, but it's duplicating the error message for some items but not others. I don't see anywhere it would do that. Hope you can find the error.
Javascript code to display the message:
Then I just write the message like this:
It duplicates the message for some reason. I don't see any reason why.
Here is the script in action
Javascript code to display the message:
Code: Select all
<script type="text/javascript">
window.onload = function()
{
timedHide(document.getElementById('errormess'), 500);
}
function timedHide(element, seconds)
{
if (element) {
setTimeout(function() {
element.style.display = 'none';
}, seconds*1000);
}
}
</script>
Code: Select all
echo "<span id='errormess'><big><b><center><font color='red'>You do not have enough money to purchase this item</font></center></b></big></span>";
Here is the script in action
Code: Select all
<script type="text/javascript">
window.onload = function()
{
timedHide(document.getElementById('errormess'), 500);
}
function timedHide(element, seconds)
{
if (element) {
setTimeout(function() {
element.style.display = 'none';
}, seconds*1000);
}
}
</script>
<?php
if(isset($_GET['randid'])) {
$id = $_SESSION['userid'];
$randid=$_GET['randid'];
$sql = "SELECT * FROM usershop WHERE randid='$randid'";
$user_query = mysqli_query($db_conx, $sql);
$numrows = mysqli_num_rows($user_query);
while ($row = mysqli_fetch_array($user_query, MYSQLI_ASSOC)) {
if ($user_money < $row['price'])
{
echo "<span id='errormess'><big><b><center><font color='red'>You do not have enough money to purchase this item</font></center></b></big></span>";
}
?>
<script>
setTimeout(function () {
window.location.href= 'mafiawarskingdom.php?usershop=1';
},2000);
</script>