Solved

JQuery and PHP

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Passport Expiry 3 44
Jquery keyup 4 19
JavaScript let vs var 5 26
Most efficient JavaScript way to verify if variable matches any value in the list? 6 22
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…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

777 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