html - Add ( + ) more button for multiple inputs -


i have multiple input form add feature first input visible , others hidden , when add more button clicked, show next input 8. keep id's way are. how go that? thank you.

<label for="stop1">stop 1 :</label>  <input type="text" id="stop1" name="stop1" /><br /> <label for="stop2">stop 2 :</label>  <input type="text" id="stop2" name="stop2" /><br /> <label for="stop3">stop 3 :</label>  <input type="text" id="stop3" name="stop3" /><br /> <label for="stop4">stop 4 :</label>  <input type="text" id="stop4" name="stop4" /><br /> <label for="stop4">stop 5 :</label>  <input type="text" id="stop5" name="stop5" /><br /> <label for="stop6">stop 6 :</label>  <input type="text" id="stop6" name="stop6" /><br /> <label for="stop7">stop 7 :</label>  <input type="text" id="stop7" name="stop7" /><br /> <label for="stop8">stop 8 :</label>  <input type="text" id="stop8" name="stop8" /><br /> 

thank again.

you can try :

    <script type="text/javascript">      int countinput = 1;      function showinput(){         document.getelementbyid("stop"+(countinput +1)).style.display = 'block';     }   function onloadfunction(){     var inputs = document.getelementsbytagname("input");      (var = 0; < inputs.length; i++) {          var id = inputs[i].getattribute("id");          if ( id != "stop1" ) {              document.getelementbyid("stop"+countinput).style.display = 'block';         }     countinput++;     }      countinput = 1;  } </script>    <label for="stop1">stop 1 :</label>  <input type="text" id="stop1" name="stop1" /><br /> <label for="stop2">stop 2 :</label>  <input type="text" id="stop2" name="stop2" /><br /> <label for="stop3">stop 3 :</label>  <input type="text" id="stop3" name="stop3" /><br /> <label for="stop4">stop 4 :</label>  <input type="text" id="stop4" name="stop4" /><br /> <label for="stop4">stop 5 :</label>  <input type="text" id="stop5" name="stop5" /><br /> <label for="stop6">stop 6 :</label>  <input type="text" id="stop6" name="stop6" /><br /> <label for="stop7">stop 7 :</label>  <input type="text" id="stop7" name="stop7" /><br /> <label for="stop8">stop 8 :</label>  <input type="text" id="stop8" name="stop8" /><br />  <button type="button" onclick="showinput"></button> 

just call onloadfunction onload atribbute of page , might works


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -