Solved

just gauge loop

Posted on 2013-05-14
3
767 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
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.
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…

911 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

24 Experts available now in Live!

Get 1:1 Help Now