Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
846 B
1
Indexable
Never
<!DOCTYPE html>
<html>
<head>
  <title>Dynamic Input Fields</title>
  <script>
    function createInputFields() {
      var numFields = document.getElementById("numFields").value;
      var container = document.getElementById("inputContainer");
      container.innerHTML = ""; // Clear previous fields

      for (var i = 0; i < numFields; i++) {
        var input = document.createElement("input");
        input.type = "text";
        input.name = "field" + (i + 1);
        container.appendChild(input);
        container.appendChild(document.createElement("br"));
      }
    }
  </script>
</head>
<body>
  <label for="numFields">Number of Input Fields:</label>
  <input type="number" id="numFields" min="1" max="10" value="1">
  <button onclick="createInputFields()">Create Fields</button>

  <div id="inputContainer"></div>
</body>
</html>