Solved

JQuery and PHP

Posted on 2014-02-01
2
288 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 30

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 30

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

19 Experts available now in Live!

Get 1:1 Help Now