Jump to content

jQuery progressbar issue


chrisrulez001

Recommended Posts

Hi

 

I'm reading from a MySQL database and then looping though the results with PHP.

 

I'm having an issue of using a progress bar within the loop, it's showing the progress bar but it isn't reading the value of a hidden field with the value.

 

The value of the progress bar should be 200 (value in hidden field) but it's just not showing

 

I've uploaded an image of what's happened.

 

Is there something obvious that I'm not seeing?

 

PHP:

<?php
$List = $this->conn->query("SELECT
			    users.username as Username,
			    challenge.item as Item, SUM(challenge.cost) as Cost
			    FROM users
			    LEFT JOIN challenge
			    ON users.ID = challenge.user_id
			    GROUP BY users.username");
$List->execute();

$row = $List->fetchAll(PDO::FETCH_ASSOC);

echo "<div id=\"Challenge\">";
foreach($row as $user)
{
	echo "<div class=\"ChallengeHeader\">";
	echo $user['Username'];
	echo "<span id=\"ChallengeAction\"><input data-index=\"".$user['Username']."\" type=\"submit\" class=\"ChallengeExpand\" id=\"Expand\" value=\"Expand\" /></span>";
	echo "</div>";
		
	echo "<div id=\"".$user['Username']."\">";
	echo "<div class=\"ProgressBar\"></div>";
	echo "<input class=\"Value\" type=\"hidden\" value=\"".$user['Cost']."\">";
	echo "</div>";
}
echo "</div>";
?>

jQuery:

$(document).ready(function(){
    $("#Challenge").each(function(){
    var $div = $(this);
	
    var val = $div.find(".Value").val();
    $div.find(".ProgressBar").progressbar({
        max: 600,
	value : val
    });
	
    if($div.find(".ProgressBar").progressbar("value") <= 500)
    {
	$div.find(".ProgressBar").css({ 'background': 'White' });
	$div.find(".ProgressBar > div").css({ 'background': 'LightGreen' });
    }
    else
    {
	$div.find(".ProgressBar").css({ 'background': 'White' });
	$div.find(".ProgressBar > div").css({ 'background': 'Red' });
    }
    });
})

post-172251-0-58692300-1472316358_thumb.png

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.