473,403 Members | 2,323 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

How to create dynamic icons giving them classes?

I am getting id of the passengers from a php file,using Ajax code.The number of icons defined by the data coming from php, and the icons(same with appearance) must be shown in the html page.The icons must be callable because I am using bootstrap popover ,when the user come to some icon the information about passsenger must be shown in popup.How can I do that?
Here is script
Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript">
  2.  
  3.          $(document).ready(function() {
  4.           $.getJSON("Stations.php", function(jsonData){  
  5.           $.each(jsonData, function(key,value) {
  6.           $('#selectStation')
  7.          .append($("<option></option>")
  8.          .attr("value",key)
  9.          .text(value.name)); 
  10.  
  11.       });
  12.   });
  13. });
  14. function sta_callStation(sel){
  15.  $('#noOfPassengers, #infoOfPassengers, #distType,#distParams').empty();
  16.        $('#sta_numberOfIcons').empty();
  17.         $.getJSON('Stations.php', function(station){
  18.  
  19.             $.each(station, function(sta_key, sta_value) {
  20.  
  21.             if(sel.value==sta_key)
  22.             {
  23.               $.each(sta_value.passengers, function(j,passengers) 
  24.             {
  25.  
  26.               $('#sta_numberOfIcons').append('<i class="icon-user"></i>');
  27.  
  28.              });
  29.             }
  30.       });
  31.  
  32.       });
  33.       }
  34.  
here is the html code:
Expand|Select|Wrap|Line Numbers
  1. İstasyonlar
  2.      <select name="selectStation" id="selectStation" onchange="sta_callStation(this);"></select>
  3.  
  4.           <div id="noOfPassengers"><strong>İstasyondaki Yolcu Sayısı:</strong></div>
  5.  
  6.           <a href="#" id="sta_numberOfIcons" rel="popover" class="pas_icon"> </a>
  7.  
  8.           ></div>
Apr 10 '13 #1
10 1424
Rabbit
12,516 Expert Mod 8TB
I am having trouble understanding what you want to do. Some code would be nice.
Apr 11 '13 #2
@Rabbit I will edit my question.
Apr 11 '13 #3
Rabbit
12,516 Expert Mod 8TB
Did you edit your description? Because I still have trouble understanding what you're trying to say.
Apr 11 '13 #4
@Rabbit yes and actually firstly I wanted to create icons dynamically and to give to ids acording to coming data from php.But I couldn't do that, my instructor say that instead of giving them ids, define them with classes.After assign operation, I will call the icons with their class info in another js function called showPassenger(this), and in it I will write getJSON to get the information about passenger(from, where, waiting time they are in another php file called Passengers.php),I will show that info in popover function.
Apr 11 '13 #5
Rabbit
12,516 Expert Mod 8TB
You're going to have to define what you mean by icon. Because you seem to be referring to the i element. But that is just for italics, not an icon. So you seem to be using a definition of icon that is unknown to me.

It would help if you posted what the HTML looks like before any action is taken. Then list the steps that trigger the dynamic change. And what the HTML should look like after the change.
Apr 11 '13 #6
Rabbit
12,516 Expert Mod 8TB
Please attach the screenshots to the post itself. Firewalls tend to block online storage. I would also rather you post the code than screenshots.
Apr 12 '13 #9
@Rabbit my code is a bit long.
https://drive.google.com/#folders/0B...Ex5UWFWenFaWE0
Here is the all project
Apr 13 '13 #10
Rabbit
12,516 Expert Mod 8TB
I don't think you understand when I said our firewalls block external storage sites.

Please attach all relevant information to the threads themselves and not rely on external storage. I don't need all your code. Just the part that relates to what you're trying to do.
Apr 14 '13 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Cindy | last post by:
hi, Can someone point me to a website where I can find a "create dynamic rows" javascript that work for IE, NS6 & NS7? Thank You. regards, Cindy
7
by: Cindy | last post by:
"kaeli" <infinite.possibilities@NOSPAMatt.net> wrote in message news:MPG.197482677bbc284b989702@nntp.lucent.com... > In article <bed8e3$m6r$1@mawar.singnet.com.sg>, stayhardsg@yahoo.com.sg >...
3
by: BlueSky | last post by:
Hi All, I am planning to create dynamic pdf documents in .NET ( for example, I will have to create tables with user input rows and columns). Can anyone recommend me a 3rd party component that is...
0
by: PughDR | last post by:
As the subject of this topic suggestions I am trying to find a way to use ASP, SQL Server, Com+ and Crystal Reports 8.5 to Create Dynamic PDF Reports Over The Web, but the only article I found that...
7
by: kalkotarmr | last post by:
How to Create Dynamic Tables in MS-Access? I will just pass the Arguments and the Code will Create the tables dynamically/run-time.
5
by: plsHelpMe | last post by:
How to create dynamic javascript arrays using dojo toolkits Hello frens, I am in a big trouble. My objective is: I am having some categories shown by differnent radio buttons, on the click of...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
4
by: Michael Munch | last post by:
Hi I want to read the value of af text-field, create dynamic, in a form. Se below a small test-site to do that (but readning fails): I use the function Test_Read for reading the value from the...
4
by: Sunny | last post by:
Hi, Is there a way in javascript to create Dynamic arrays or arrays on fly. Something Like: var "ptsgN"+sd = new Array(); Here sd is incrementing by 1. I have lots of data that I am...
8
by: remya1000 | last post by:
i'm using VB \ ASP.NET. i'm trying to display some values in Gridview. but i don't know how many columns i need to display. at run time only i will come to know how many columns i need to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.