Solved

just gauge loop

Posted on 2013-05-14
3
776 Views
Last Modified: 2013-06-10
I cant seem to get this to loop just gauge I need to create them dynamically
here what I tried
<script>

for (var i=0;i<cars.length;i++)
{ 
 var g = new JustGage({
    id: "gauge", 
    value: 67, 
    min: 0,
    max: 100,
    title: "Conversion rate"
	
  }); 
  
  
  }
 
</script>

Open in new window

0
Comment
Question by:beridius
  • 2
3 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 39164102
what is not working for you?
if u wanna have multiple gage divs in your page then first create the external div:
<div id="gauge_list"></div>

Open in new window

then in the loop create div for each new gage, assign the id accordingly and append to the external div:
<script>
for (var i=0;i<cars.length;i++)
{ 
//create new gage
 var g = new JustGage({
    id: "gauge"+i, 
    value: 67, 
    min: 0,
    max: 100,
    title: "Conversion rate"	
  }); 

//create new gage div
var newgageDiv = '<div id=' + g.id +' class="200x160px"></div>';

//add new gage div to page
$('#gauge_list').append(newgageDiv); 
  }
 
</script>

Open in new window

0
 
LVL 2

Author Comment

by:beridius
ID: 39164114
I tried you script and I must be doing something wrong as did not work  here my whole page
<script src="js/raphael.2.1.0.min.js"></script>
<script src="js/justgage.1.0.1.min.js"></script>
<div id="gauge_list"></div>
<script>
for (var i=0;i<cars.length;i++)
{ 
//create new gage
 var g = new JustGage({
    id: "gauge"+i, 
    value: 67, 
    min: 0,
    max: 100,
    title: "Conversion rate"	
  }); 

//create new gage div
var newgageDiv = '<div id=' + g.id +' class="200x160px"></div>';

//add new gage div to page
$('#gauge_list').append(newgageDiv); 
  }
 
</script>

Open in new window

0
 
LVL 42

Accepted Solution

by:
sedgwick earned 500 total points
ID: 39164134
here the whole page.
make sure to place the gage javascript files in the same folder where your html.
<HTML>
<head>
<title>Gauge Page</title>
</head>
<body>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
  <script src="raphael.2.1.0.min.js"></script>
<script src="justgage.1.0.1.min.js"></script>
<div id="gauge_list"></div>
<script>
for (var i=1;i<4;i++)
{ 
	//create new gage div
	var newgageDiv = '<div id=gauge' + i +' class="50x40px"></div>';

	//add new gage div to page
	$('#gauge_list').append(newgageDiv); 
	
	//create new gage
	var g = new JustGage({
		id: "gauge"+i, 
		value: i*10, 
		min: 0,
		max: 100,
		title: "Conversion rate " +i	
	}); 
}
</script>
</body>

</HTML>

Open in new window

0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Sorting a string 1 30
how can i test my code? 1 38
How can I enable / disable a text box with a checkbox 3 19
If condition on Html with Asp 11 17
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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