Solved

JQuery and PHP

Posted on 2014-02-01
2
291 Views
Last Modified: 2014-02-01
Sorry, I have to ask this question again but in a different way:  
How do you place a PHP variable into a JQuey Script?

See currentAmount:  below
<?php
function progess() {
$goal = "23";
}
?>

<?php progrss(); ?>

<?php progressBar(); ?>
<script type="text/javascript">
$(document).ready(function(){
    $('#sample_goal').goalProgress({
        goalAmount: <?php echo '1000'; ?>,
        currentAmount: <?php echo $goal; ?>,
        textBefore: 'Amount Raised $',
        textAfter: ''
    });
});
</script>

Open in new window


What am I doing wrong?
0
Comment
Question by:rgranlund
  • 2
2 Comments
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 500 total points
ID: 39826930
Use this:
<?php
function progess() {
    return "23";
}
$goal = progress();
?>

Open in new window

0
 
LVL 31

Expert Comment

by:Marco Gasi
ID: 39826932
The problem was that your variable $goal was visible only within the function: about variable scope
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now