2

Possible Duplicate:
pass php variable value to javascript

I want to create a progress bar, the value of the progress will be coming from PHP.

<div class="prog" id="progressbar"></div>
<label id="amount">
<?php echo $cast; ?></label>

I have this kind of javascript.

<script>
$(function() {
    $( "#progressbar" ).progressbar({
    value: 0
    });
});
</script>

How can I throw the value $cast in my script?

0

2 Answers 2

2
<script>
$(function() {
    $( "#progressbar" ).progressbar({
    value: <?php echo intval($cast);?>
    });
});
</script>
Sign up to request clarification or add additional context in comments.

3 Comments

but it is display the progress at this time. When $cast change the value, it isn't updated.
then you have to use ajax to update it repatedly
the progress bar did not change :(((
0

Javascript is run in Client (browser), while PHP is run on server. You can't cast varble from PHP to javascript like that. With print progress:

 <?php echo $cast; ?>

it just display the value of current run time, it is not updated. If you have a link to check value of progress bar, just use ajax POST or GET to make change.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.