Skip to content

Instantly share code, notes, and snippets.

@hzbd
Created August 16, 2014 17:40
Show Gist options
  • Save hzbd/3a4f7ee16f2768132bf9 to your computer and use it in GitHub Desktop.
Save hzbd/3a4f7ee16f2768132bf9 to your computer and use it in GitHub Desktop.
auto adding a element by js.
<html>
<head>
<title>Testing</title>
<script language="javascript">
fields = 1;
function addInput() {
if (fields < 4) {
document.getElementById('text').innerHTML += "<input type='file'"+ "name=" + "thumdals" + fields + " value=''/><br />";
fields += 1;
} else {
document.getElementById('text').innerHTML += "Only 3 upload fields allowed.";
document.form.add.disabled=true;
}
}
</script>
</head>
<body>
<form name="form">
<div id="text"></div>
<input type="button" onclick="addInput()" name="add" value="Add input field" />
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment