Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

just gauge loop

Posted on 2013-05-14
3
Medium Priority
?
852 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

664 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