Heya everyone,
I've been working on a website where I had an idea to use DHTML to print out multiple inputs to be used as an array. The DHTML prints out properly in a doc.write test, but when I submit the form, it's always read as "Array".
I tried a count() on it, always comes up as one, so just to see, I printed out the variable's ($body)'s values. $body[0] came up to "A", [1] was r, etc....
I've been using PHP for a while now (but only just started DHTML), and I've encountered Array before, but I could at least pull values before.
Here's a scaled down version of my code:
(the Sending Page)
<script language="javascript">
function pagefields()
{
var fieldcount = document.articlepost.fieldcount.value;
var fieldtext;
var fieldid;
for ($i=1;$i<= fieldcount;$i++)
{
fieldid = $i-1;
if (fieldtext)
{
fieldtext = fieldtext + "<tr><th>Page: " + $i + "</th></tr><tr><td><input type=text name=body[" + fieldid + "] cols=63 rows=5></td></tr>\n";
}else{
fieldtext = "<tr><th>Page: " + $i + "</th></tr><tr><td><input type=text name=body[" + fieldid + "] cols=63 rows=5></td></tr>\n";
}
}
storydiv.innerHTML= "<table width=100%>" + fieldtext + "</table>";
}
</script>
<form action=articles.php method=post name=articlepost>
<select name="fieldcount" onChange="pagefields();">
<option value="1"> 1
<option value="2"> 2
<option value="3"> 3
<option value="4"> 4
<option value="5"> 5
<option value="6"> 6
<option value="7"> 7
<option value="8"> 8
<option value="9"> 9
<option value="10"> 10
</select>
<div id="storydiv">
</div>
</form>
(the Processing Page)
$newcount = count($body);
echo "$newcount\n";
echo "body: $body AND ".$body[0]." AND ".$body[1]."<br>\n";
$newcount always ends up as 1, no matter how many input fields are chosen, and $body[0] is always "A"....go through the numbers, and it spells out "Array".
I'm going nuts on this......any help would be greatly appreciated
-Infinity-