0

When I try to update the width property of the css with a value from the array (a percentage value) and assign it to the .css() property of my object it will not change the width, but if I enter it directly then it works:

function updateCurrentAssetUploadProgressBox() {

var activeWorkflows = new Array();

activeWorkflows[0] = "15"; //progress percentage
activeWorkflows[1] = "MyTestAsset.jpg"; //asset name

var percentComplete = activeWorkflows[0] + "%"; // THIS WILL NOT WORK

$('#progressBox #metaAndLinksRow #itemName').html(activeWorkflows[1]);
//$('#progressBox #progressRow #progressBar').css('width', 'percentComplete');    // DOES NOT WORK
$('#progressBox #progressRow #progressBar').css('width', '15%');    // WORKS FINE

}

Thank you.

3 Answers 3

3

No quotes. You're passing 'percentComplete' as a string. Remove the quotes in the argument:

function updateCurrentAssetUploadProgressBox() {

    var activeWorkflows = new Array();

    activeWorkflows[0] = 15; //progress percentage (INT should be unquoted)
    activeWorkflows[1] = "MyTestAsset.jpg"; //asset name

    var percentComplete = activeWorkflows[0] + "%";

    $('#progressBox #metaAndLinksRow #itemName').html(activeWorkflows[1]);
    $('#progressBox #progressRow #progressBar').css('width', percentComplete); // Pass as a variable, unquoted

}
Sign up to request clarification or add additional context in comments.

Comments

1

Replace:

$('#progressBox #progressRow #progressBar').css('width', 'percentComplete');

with:

$('#progressBox #progressRow #progressBar').css('width', percentComplete);

Comments

1

Remove the quotes around percentComplete.

Change:

$('#progressBox #progressRow #progressBar').css('width', 'percentComplete'); 

to

$('#progressBox #progressRow #progressBar').css('width', percentComplete); 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.