Hey all I have a question for ya. Using the example that I have been using I want to create a bunch of text boxes, loop through them and put them into an array, then submit the array. Here is my code.
I have create a button
that will run this function
so I now hace this array inputArray and I want to submit that data in a post. Will this work?
How can I submit this array
thanks
-T
-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!
Code:
<html>
<head>
<title>Want to see if I can do this</title>
<script type="text/javascript">
var fieldCount = 0;
function addBreak()
{
var aBreak = document.createElement('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();
}
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 = "";
}
function submitAll()
{
var collectArray = new Array();
// 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") {
collectArray.push(inputArray[a].value);
}
}
// now I need to submit the array
}
</script>
</head>
<body>
<?php
$getStuff = $_POST['stuff'] ;
echo $getStuff;
?>
<!--<form name="myform" action="7.php" method="POST"> -->
<div id="topOne">
<input type="button" value="Old Way" onclick="AddField()">
<div id="fieldHere">
</div>
<input type="button" value="Get Info" onclick="getInfo()"/>
<input type="button" value="Clear" onclick="clearAll()"/>
<input type="button" value="Submit" onclick="submitAll()"/>
</div>
</form>
</body>
</html>
I have create a button
Code:
<input type="button" value="Submit" onclick="submitAll()"/>
Code:
function submitAll()
{
var collectArray = new Array();
// 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") {
collectArray.push(inputArray[a].value);
}
}
// now I need to submit the array
Code:
document.submit(inputArray);
How can I submit this array
thanks
-T
-How important does a person have to be before they are considered assassinated instead of just murdered?
-Need more cow bell!!!