Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I create icons dynamically using CSS class?
    primarykey
    data
    text
    <p>I am getting id of the passengers from a php file,using Ajax getJSON function.The number of icons defined by the number of passengers 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 bootstap popover ,when the user come to some icon the information abaot passsenger must be shown in popup. Here, I initialize the combobox;</p> <pre><code>$(document).ready(function() { $.getJSON("Stations.php", function(jsonData){ $.each(jsonData, function(key,value) { $('#selectStation') .append($("&lt;option&gt;&lt;/option&gt;") .attr("value",key) .text(value.name)); }); }); }); </code></pre> <p>Here is the js code that I tried,it is called from select option in html to choose station:</p> <pre><code>function sta_callStation(sel){ $('#sta_numberOfIcons').empty(); $.getJSON('Stations.php', function(station){ $.each(station, function(sta_key, sta_value) { if(sel.value==sta_key){ $.each(sta_value.passengers, function(j,passengers) { $('#sta_numberOfIcons').append('&lt;i class="icon-user "&gt;&lt;/i&gt;') }); } }); } ); } </code></pre> <p>sel is parameter for passing station id(from 1 to 5) from Stations.php, I am calling this function from select option tags. From sta_value.passengers just the numbers(from 1 to 20, they are randomly produced) are returned for the for each passenger icon. Here the icons have the same properties, but I want them to be different according to passenger id, because after I will call them for popover function. Here html code part:</p> <pre><code>&lt;select name="selectStation" id="selectStation" onchange="sta_callStation(this);"&gt; &lt;/select&gt; &lt;div id="noOfPassengers"&gt;&lt;strong&gt;İstasyondaki Yolcu Sayısı:&lt;/strong&gt;&lt;/div&gt; &lt;a href="#" id="sta_numberOfIcons" rel="popover" class="pas_icon"&gt; &lt;/a&gt; </code></pre> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload