Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Look at for() statements for arrays.</p> <pre><code>for( var i = 0; i &lt; myarray.length; i++ ){ // ...statements ie document.write("&lt;li&gt; "+myarray[i]); } </code></pre> <p>and for(in) for associative arrays and objects.</p> <pre><code>obj = document; /* or "input" in your case */ for (var key in obj { document.write("&lt;li&gt; "+key+":"+obj[key]); } </code></pre> <p><strong>Update:</strong></p> <p>In your case I would use an associated array so I do not need to loop through a table, (although if anybody lands on this page based on the question those people may want what is above). An associated array shortens things considerably. Doing this using an associated array may end up looking something like this.</p> <pre><code>// $table is an associated array of dollar rates $table = { euro:1.37, Yuan:0.16, yen:0.0096} /* associated arrays can be accessed in two ways, as a property or [] index of which allows a variable to be used. using the indexOf method helps use today. */ yen = 4500; alert("value of yen in dollars "+ yen * $table.yen); alert("value of yen in dollars "+ yen * $table['yen']); // basic HTML interface to dropdown and input text bos var htmldropdownobject = document.getElementById("convertFrom"); /* document.querySelector could be used, I'm old school */ var htmltextinputobject = document.getElementById("textbox_amount"); var typeOfMoney = htmldropdownobject.options[htmldropdownobject.selectedIndex].value; var amount = htmltextinputobject.value; // conversion. alert("value of " + typeOfMoney + " in dollars"+ amount * $table.[typeOfMoney]"); </code></pre> <p>Ultimately you need to write the html and code, this is mainly to point you in the direction, and not an attempt to write your code.</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.
    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