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?

Community
  • 1
  • 1
SMDC
  • 709
  • 1
  • 9
  • 17

2 Answers2

2
<script>
$(function() {
    $( "#progressbar" ).progressbar({
    value: <?php echo intval($cast);?>
    });
});
</script>
Hanky Panky
  • 46,730
  • 8
  • 72
  • 95
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.

cat
  • 357
  • 1
  • 5
  • 14