javascript - HTML Add value in textbox -


i want add value in text box. text box created default value equal 10, button use function adding new text box limit 4. therefore, want add value continuously text box 1 text box 4

example:

text box 1 value = 10

text box 2 value = 20

text box 3 value = 30

text box 4 value = 40

how can this?

<script type="text/javascript">     //adding new line item function     var = 1;     function addnew(){         if (i <=3){ //if don't want limit, remove if condition             i++;             var div= document.createelement('div');             div.innerhtml = '<input type="text" name="lineitem_'+i+'" maxlength="2" size="2"><input type="button" onclick="removekid(this)" value="-">';             document.getelementbyid('addingitem').appendchild(div);         }     } </script> 

you want add value continuously text box 1 text box 4 ,so while loop more better here

 var = 1;     function addnew(){         while(i < 4 ){             i++;             var div = document.getelementbyid("addingitem");             div.innerhtml += '<br>text box '+i+' <input type="text" name="lineitem_'+i+'" maxlength="2" size="2" value="'+i*10+'"><input type="button" onclick="removekid(this)" value="-">';                     }     } 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

python 3.x - PyQt5 - Signal : pyqtSignal no method connect -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)