Note that there are some explanatory texts on larger screens.

plurals
  1. POhow do i get these Object Key Values into the textboxes?
    text
    copied!<p>I'v been trying to get the values of each key in a object string into textboxes but having issues</p> <p>if anyone could hep me out and point me in the right direction as to where im going wrong id appreciate it thank you.</p> <p>this is a small version of what im working with.</p> <pre><code>&lt;form name=formtest&gt; &lt;input type=text id = text1 size=10 value=""/&gt; &lt;input type=text id = text2 size=10 value=""/&gt; &lt;input type=text id = text3 size=10 value=""/&gt; &lt;input type=text id = text4 size=10 value=""/&gt; &lt;input type=text id = text5 size=10 value=""/&gt; &lt;input type=text id = text6 size=10 value=""/&gt; &lt;input type=text id = text7 size=10 value=""/&gt; &lt;input type=text id = text8 size=10 value=""/&gt; &lt;input type=button id = calculate value = calculate onclick = calculate()/&gt; &lt;/form&gt; &lt;script type="text/javascript"&gt; function calculate() { var attackerTroops = {"Peasants":"222,111","Militia":"333,444","Spies":"22,1","Arsonists":"1111,1000"}; var peas = 'Peasants'; var mili = 'Miltia'; var spies = 'Spies'; var arson = 'Arsonists'; console.log(attackerTroops[peas]); console.log(attackerTroops[mili]); console.log(attackerTroops[spies]); console.log(attackerTroops[arson); document.formtest.text1.value =(peas[0]) document.formtest.text2.value =(peas[1]) document.formtest.text3.value =(mili[0]) document.formtest.text4.value =(mili[1]) document.formtest.text5.value =(spies[0]) document.formtest.text6.value =(spies[1]) document.formtest.text7.value =(arson[0]) document.formtest.text8.value =(arson[1]) } &lt;/script&gt; </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