Here is the problem that I am having;
1. I am learning.
2. I have so many questions.
So Here I go and I will be asking many. Thanks ahead of time.
I created this script that will create many text boxes depending on how many times I press the button.
I use the
element in this script:
The problem is that all the text boxes are right next to each other. If I try and do somting like
and I get errors when I run the code. Here is what I am asking:
1. When I am running
How can I add multiple things here, like text boxes, breaks or labels?
Thanks again for your help, remember I am still learning.
-T
-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!
1. I am learning.
2. I have so many questions.
So Here I go and I will be asking many. Thanks ahead of time.
I created this script that will create many text boxes depending on how many times I press the button.
I use the
Code:
document.getElementById('fieldHere').appendChild(addField);
element in this script:
Code:
<html>
<head>
<title>Want to see if I can do this</title>
<script type="text/javascript">
var fieldCount = 0;
function addLabel()
{
var aLabel = document.createElement(' ')
}
function AddField()
{
fieldCount++;
var addField = document.createElement('input');
addField.type = 'text';
addField.name = 'field' + fieldCount;
addField.id = 'field' + fieldCount;
document.getElementById('fieldHere').appendChild(addField);
}
function getInfo()
{
// Get the top level div and then searc for all the inputs
var inputArray = document.getElementById("topOne").getElementsByTagName("input");
var inputArrayLength = inputArray.length;
for (a = 0; a < inputArrayLength; a++) {
//filter out the textboxes here
if (inputArray[a].type == "text") {
alert(inputArray[a].value);
}
}
}
function clearAll()
{
document.getElementById('fieldHere').innerHTML = "";
}
</script>
</head>
<body>
<div id="topOne">
<input type="button" value="New Field" onclick="AddField()">
<div id="fieldHere">
</div>
<input type="button" value="Click Me" onclick="getInfo()">
<input type="button" value="Clear" onclick="clearAll()">
</div>
</body>
</html>
Code:
function addBreak()
{
var aBreak = "<br />";
document.getElementById('fieldHere').appendChild(aBreak);
}
function AddField()
{
fieldCount++;
var addField = document.createElement('input');
addField.type = 'text';
addField.name = 'field' + fieldCount;
addField.id = 'field' + fieldCount;
document.getElementById('fieldHere').appendChild(addField);
addBreak();
}
1. When I am running
Code:
document.getElementById('fieldHere').appendChild(addField);
Thanks again for your help, remember I am still learning.
-T
-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!