Created
August 16, 2014 17:40
-
-
Save hzbd/3a4f7ee16f2768132bf9 to your computer and use it in GitHub Desktop.
auto adding a element by js.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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