I am trying to help a friend with making his website school project, but I ran into a problem. It was meant to have 3 text boxes with a button that can add more text boxes, I tried with document.write
but it overwrites the whole page so I looked it up and I found out about document.createElement
, which doesn't seem to work as well.
I don't know if anything in my code is incorrect.
<!DOCTYPE html>
<html>
<head>
<style>
.input {
margin-top: 50px;
}
.input .submit {
float: left;
}
.add {
margin-left: 100px;
margin-top: 50px;
width: 50px;
height: 50px;
font-size: 30px;
}
.gen {
float: right;
margin-right: 100px;
width: 400px;
height: 50px;
font-size: 25px;
}
.output {
position: fixed;
margin-top: 100px;
float: right;
margin-left: 400px;
}
</style>
<script language="javascript" type="text/javascript">
var input = document.createElement("<p>Hello</p>");
var container = document.getElementsByClassName("buttons");
container.appendChild(input);
</script>
</head>
<body>
<form class="buttons">
<input type="text" class="input">
<input type="submit" class="submit">
<br>
<input type="text" class="input">
<input type="submit" class="submit">
<input type="button" class="gen" value="Click to generate a random word">
<input type="text" class="output">
<br>
<input type="text" class="input">
<input type="submit" class="submit">
<br>
</form>
<input type="button" class="add" value="+" >
</body>
</html>