Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

JQuery and PHP

Posted on 2014-02-01
2
Medium Priority
?
319 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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…
Suggested Courses
Course of the Month21 days, 7 hours left to enroll

804 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