I'm looking to create variable sized forms. So the user can enter anywhere from 2 items (each item is 2 text fields), to 3.04x1023
I tried the following code (obviously broke).
It's easy to display forms of variable length, but not process them.
I don't want the field names to use characters other than A-Za-z0-9_ for compatibility reasons.
Any advice greatly appreciated. i've been researching how to do this for quite some time.
<?php
if (isset($submit)) {
if (isset($formSize)) {
print '
<form action="test.php" method="post">
<table border="0">
';
for($i=0;$i<$formSize;$i++){
print '
<tr>
<td><input type="text" name="formVar_' . $i . '" value="" size="3" maxlength="3"></td>
<td><input type="text" name="formVar_' . $i . '" value="" size="3" maxlength="3"></td>
</tr>
';
}
print'
</table>
<input type="submit" name="submit" value="Submit">
</form>
';
} else {
print 'values:';
for($i=0;$i<sizeof($argv);$i++){
print $formVar_ . $i . "\n";
}
}
} else {
print '
Size:
<form action="test.php" method="post">
<table border="0">
<tr>
<td><input type="text" name="formSize" value="" size="3" maxlength="3"></td>
</tr>
</table>
<input type="submit" name="submit" value="Submit">
</form>
';
}
?>