CBR Posted October 13, 2008 Share Posted October 13, 2008 <script type="text/javascript"> Event.observe(window, 'load', function() { manualPB2 = new JS_BRAMUS.jsProgressBar( $('element6'), 85, { barImage : Array( 'images/bramus/percentImage_back4.png', 'images/bramus/percentImage_back3.png', 'images/bramus/percentImage_back2.png', 'images/bramus/percentImage_back1.png' ) } ); }, false); </script> In the above code I would like to insert an array where 85 is listed. for instance I would like to put in there the below. $arrayname = 'arraynameresult'; So putting in $arrayname where the 85 is will not work, I have tried over and over. any ideas? Quote Link to comment Share on other sites More sharing options...
Acs Posted October 13, 2008 Share Posted October 13, 2008 I really don't understand what you want. Quote Link to comment Share on other sites More sharing options...
CBR Posted October 13, 2008 Author Share Posted October 13, 2008 Take a look at the top code. It has a place where it has an 85. I would like to get the number out of a mysql query for instance 88, and populate that new number where the 85 is. Does that make sense? This is for a progress bar that I plan to use to show status of some goals. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 13, 2008 Share Posted October 13, 2008 If you're not in PHP there, you have to go into PHP, echo the variable and then leave PHP: <script type="text/javascript"> Event.observe(window, 'load', function() { manualPB2 = new JS_BRAMUS.jsProgressBar( $('element6'), <?php echo $arrayname ?> , { barImage : Array( 'images/bramus/percentImage_back4.png', 'images/bramus/percentImage_back3.png', 'images/bramus/percentImage_back2.png', 'images/bramus/percentImage_back1.png' ) } ); }, false); </script> Ken Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 13, 2008 Share Posted October 13, 2008 you need to use php tags to set javascript variables derived from php...you can't just mix them. <?php $myid = 85; ?> <script type="text/javascript"> Event.observe(window, 'load', function() { manualPB2 = new JS_BRAMUS.jsProgressBar( $('element6'), <?php echo $myid; ?>, { barImage : Array( 'images/bramus/percentImage_back4.png', 'images/bramus/percentImage_back3.png', 'images/bramus/percentImage_back2.png', 'images/bramus/percentImage_back1.png' ) } ); }, false); </script> Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 13, 2008 Share Posted October 13, 2008 <?php $a=array("john","petter","paul"); ?> <script type="text/javascript"> Event.observe(window, 'load', function() { manualPB2 = new JS_BRAMUS.jsProgressBar( $('element6'), <?php for($i=0; $i<count($a); $i++){echo $a[$i];} ?>, { barImage : Array( 'images/bramus/percentImage_back4.png', 'images/bramus/percentImage_back3.png', 'images/bramus/percentImage_back2.png', 'images/bramus/percentImage_back1.png' ) } ); }, false); </script> Quote Link to comment Share on other sites More sharing options...
CBR Posted October 13, 2008 Author Share Posted October 13, 2008 when I do that, it does not load the javascript? Here is my entire code. <?php $myid = 85; ?> <script type="text/javascript" src="js/prototype/prototype.js"></script> <script type="text/javascript" src="js/bramus/jsProgressBarHandler.js"></script> <div class="percentImage1" id="element6">[ Loading Progress Bar ]</div> <script type="text/javascript"> Event.observe(window, 'load', function() { manualPB2 = new JS_BRAMUS.jsProgressBar( $('element6'), <?php echo $myid; ?>, { barImage : Array( 'images/bramus/percentImage_back4.png', 'images/bramus/percentImage_back3.png', 'images/bramus/percentImage_back2.png', 'images/bramus/percentImage_back1.png' ) } ); }, false); </script> Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 13, 2008 Share Posted October 13, 2008 After you run it, look at the source code via your browser (view source)...what does the code look like in there? Quote Link to comment Share on other sites More sharing options...
CBR Posted October 13, 2008 Author Share Posted October 13, 2008 I got it working! It would help if I had a .php extension now wouldnt uit? Thanks for all of your help! Quote Link to comment Share on other sites More sharing options...
DarkWater Posted October 13, 2008 Share Posted October 13, 2008 I got it working! It would help if I had a .php extension now wouldnt uit? Thanks for all of your help! Yeah, that could help. xD Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.