Note that there are some explanatory texts on larger screens.

plurals
  1. POArray In Array in JSON
    primarykey
    data
    text
    <p>My javascript code;</p> <pre><code>function callDist(sel) { $.getJSON('Dist.json', function(data){ var $container = $('#parameters').empty(); $.each(data.distributions, function(i, distribution){ $.each(distribution, function(key,value) { if(distribution.type==sel.value) { alert(distribution.name); $.each(distribution.parameters, function(key, value) { $container.append(key + ':' + value + '&lt;br /&gt;'); $container.append('&lt;hr /&gt;'); }); } }); } ); }); } </code></pre> <p>My Json code;</p> <pre><code>{ "distributions":[ { "name":"Uniform", "type":1, "parameters":[{ "minValue":2 , "maxValue":4 }] }, { "name":"Normal", "type":2, "parameters":[{ "mean":5 , "standartDeviation":3 }] }, { "name":"Exponential", "type":3, "parameters":[{"lamda":2}] }, { "name":"Geometric", "type":4, "parameters":[{"probability":0.2}] } ] } </code></pre> <p>Html code;</p> <pre><code>&lt;select name="selectDistribution" class="span12" id="Options" onchange="callDist(this);" &gt; &lt;option value="0"&gt;Choose one distribution&lt;/option&gt; &lt;option value="1"&gt;Uniform&lt;/option&gt; &lt;option value="2"&gt;Normal&lt;/option&gt; &lt;option value="3"&gt;Exponential&lt;/option&gt; &lt;option value="4" &gt;Geometric&lt;/option&gt; &lt;/select&gt; </code></pre> <p>In Json there is an array that created by some distributions.when the user selects some of them from select option I am triggering callDist(sel) function. When the passed value sel is equal to distribution.type , I want to write the parameters of that distribution to a div.How can I do that?Thanks.</p>
    singulars
    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.
 

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