Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON not working in Firefox but in Chrome and Safari it works as expected
    text
    copied!<p>I've a list that autopopulates from a JSON file:</p> <pre><code>&lt;div class="conversionFormES" id="from1"&gt; &lt;label for="from"&gt;Convert From:&lt;/label&gt; &lt;select size = "10" name="from" id="from" onchange="convertUnits()"&gt; &lt;option value="from"&gt;-Select an Option-&lt;/option&gt; &lt;option value="from"&gt;Firefox&lt;/option&gt; &lt;/select&gt; &lt;/div&gt; </code></pre> <p>I added the 'Firefox' option just to make sure something was being displayed and it is.</p> <p>Any ideas what the problem could be. Just to re-iterate, it works perfectly with chrome and safari. Many thanks.</p> <p>ConvertUnits function:</p> <pre><code>function convertUnits(){ var convertObj = new Convert($("#from"), $("#to"), $("#units"), $("#result")); var measurementType = $("#from option:selected").attr("class"); var result = "invalid input"; var input = parseInt(convertObj.units.val()); // convertObj.convertUnitsFromHash(); if(measurementType == "temp"){ convertObj.convertTemp(); }else{ convertObj.convertUnitsFromHash(); } console.log('Measurement Type:', measurementType); } </code></pre> <p>JSON Script called after the HTML Form.</p> <pre><code> &lt;script&gt; // JSON: // The key is the class identifier, temp, area etc etc // Value is being used for both ID and Value when the list is being populated $(document).ready(function(){ $.getJSON('JSON/conversionJSON.json', function(data){ console.log(data); //for testing output only var list = $("&lt;ul /&gt;"); $.each(data, function (key, conversions) { console.log(key + ":" + conversions); $.each(conversions, function (index, conversion) { console.log("&lt;li&gt;Name: " + conversion.name + " :Value: " + conversion.value + "&lt;/li&gt;"); if(key == "&lt;?php echo $conversionType ?&gt;"){ $("#from").append('&lt;option class="'+key+'" id="'+conversion.value+'" value="'+conversion.value+'"&gt;'+conversion.name+'&lt;/option&gt;'); $("#to").append('&lt;option class="'+key+'" id="'+conversion.value+'" value="'+conversion.value+'"&gt;'+conversion.name+'&lt;/option&gt;'); //testing output var elem = $("&lt;li&gt;Name: " + conversion.name + " :Value: " + conversion.value + "&lt;/li&gt;").appendTo(list); } }); }); //$("#testJSON").html(list); }); }); &lt;/script&gt; </code></pre> <p>EDIT: JSON sample:</p> <pre><code>{ "angle": [ { "value": "degree", "name": "Degree(deg)" }, { "value": "radian", "name": "Radian(rad)" } ] } </code></pre>
 

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