Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to assign a javascript variable to input text field?
    primarykey
    data
    text
    <p>I've a variable called "numbers" in javascript and this variables holds 10 numbers from 0 to 9 as shown below.</p> <pre><code>var numbers = "0123456789"; </code></pre> <p>Now what I want to be able to do is assigning each of these numbers to an input text field using document.getElementByID("a") = "";, for example:</p> <pre><code>&lt;input type="text" id="a" value="" /&gt; &lt;input type="text" id="b" value="" /&gt; &lt;input type="text" id="c" value="" /&gt; &lt;input type="text" id="d" value="" /&gt; &lt;input type="text" id="e" value="" /&gt; &lt;input type="text" id="f" value="" /&gt; &lt;input type="text" id="g" value="" /&gt; &lt;input type="text" id="h" value="" /&gt; &lt;input type="text" id="i" value="" /&gt; &lt;input type="text" id="j" value="" /&gt; </code></pre> <p>Currently the following text fields above holding no values, but I want to be able to assign each of the numbers in variable "numbers" to each of the text fields above, so it would looks like this when user clicks on a button called click me.</p> <pre><code>&lt;input type="text" id="a" value="0" /&gt; &lt;input type="text" id="b" value="1" /&gt; &lt;input type="text" id="c" value="2" /&gt; &lt;input type="text" id="d" value="3" /&gt; &lt;input type="text" id="e" value="4" /&gt; &lt;input type="text" id="f" value="5" /&gt; &lt;input type="text" id="g" value="6" /&gt; &lt;input type="text" id="h" value="7" /&gt; &lt;input type="text" id="i" value="8" /&gt; &lt;input type="text" id="j" value="9" /&gt; </code></pre> <p>Also is there any way to leave a text field empty if a particular number is = 0</p> <p>Thanks in advance :)</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