Note that there are some explanatory texts on larger screens.

plurals
  1. POGetElementBy... FAIL - where's the mistake?
    primarykey
    data
    text
    <p>Hi this is my code and html in jsfiddle...</p> <p><a href="http://jsfiddle.net/vp9V6/56/" rel="nofollow">http://jsfiddle.net/vp9V6/56/</a></p> <p>and this is the .js:</p> <pre><code> function itemManager(){ var _me = null; var _goldAsk = 0; var _silverAsk = 0; var _eurusdAsk = 0; var construct = function(){ //init here _me = $(this); _bindHandlers(); _updateItem(125); } var _bindHandlers = function(){ _me.on('stockupdated', function(){ $('#gcost').text('Domanda oro: ' + (( _goldAsk / 31.1034768 ) / _eurusdAsk).toFixed(3) + ' Domanda argento: ' + (( _silverAsk / 31.1034768 ) / _eurusdAsk).toFixed(3) + ' Cambio €/$: ' + (_eurusdAsk).toFixed(3)); }); $('#calculate').on('click', function(){ alert("item gold ask(" + _goldAsk + ") vs silver ask(" + _silverAsk + ")"); }); $('#updateitem').on('click', function(){ _updateItem(250); }); $('#btnGetTotalsGold').on('click', function(){ var grammsOfGold = $('#goldGramms').val().length ? parseInt($('#goldGramms').val()) : 0; var carati = document.getElementById("carati").selectedIndex; $(".container-oro").text('Valutazione per ORO: ' + (((( _goldAsk / 31.1034768 ) / _eurusdAsk) * (document.getElementsByTagName("option")[carati].value)) * grammsOfGold ).toFixed(2) + ' Carati selezionati: ' + (document.getElementsByTagName("option")[carati].value)) }); $('#btnGetTotalsSilver').on('click', function(){ var grammsOfSilver = $('#silverGramms').val().length ? parseInt($('#silverGramms').val()) : 0; var millesimi = document.getElementById("millesimi").selectedIndex; $(".container-argento").text(' Valutazione per ARGENTO: ' + (((( _silverAsk / 31.1034768 ) / _eurusdAsk) * (document.getElementsByTagName("option")[millesimi].value)) * grammsOfSilver ).toFixed(2) + ' Titolo selezionato: ' + (document.getElementsByTagName("option")[millesimi].value)) }); }; var _updateItem = function(cost){ $.ajax({ type: 'POST', url: 'json.php', dataType: 'json', delay: 0, success: function(data){ _goldAsk = parseFloat(data.GOLD.ask); _silverAsk = parseFloat(data.SILVER.ask); _eurusdAsk = parseFloat(data.EURUSD.ask); _me.trigger('stockupdated'); } }) } setInterval( _updateItem, 60000); construct(); } window.onload = function(){ var item = new itemManager(); } </code></pre> <p>When i calculate the Silver value clicking the "btnGetTotalsSilver" the script show the result getting the "option" value but doesn't match the right one, it get the gold select box value:</p> <blockquote> <p>this: (document.getElementsByTagName("option")[carati].value))</p> <p>not this: (document.getElementsByTagName("option")[millesimi].value))</p> </blockquote> <p>why?</p> <p>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