Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

just gauge loop

Posted on 2013-05-14
3
Medium Priority
?
878 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:Meir Rivkin
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:
Meir Rivkin earned 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to create an extensible mechanism for linked drop downs.
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…
Suggested Courses

877 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