P
phpCodeHead
I am needing to determine how to go about validating that a field in
my form contains only a positive integer. I know that this is fairly
simple if the form contains only one element to be validated; but, a
much bigger challenge ( to me anyway, that's why I'm coming to the
pros! ) when I don't know exactly how many fields may appear on the
form as it is dynamically generated based upon the number of line
items to be received on a purchase order. (i.e. if there are 10 items
to receive in; I will have 10 text fields to enter "quantity received"
into. Obviously, I want to be sure that only a positive integer is
accepted into these fields.
I apologize for pasting in SO MUCH of my code, but it gives you the
insight as to how my form elements are getting named...
The field I'm needing to validate is referenced in the code below as:
<td><input type="text" size="7" maxlength="6" name="<?php echo
'amtReceived_'.$poLineItems[VItemID]; ?>" value="" /></td>
Here is the code that generates the dynamic number of table rows/form
elements:
<?php
while ($poLineItems = mysql_fetch_assoc($result)) {
?>
<tr class="lineitem">
<td><?= $poLineItems[VItemID] ?></td>
<td><?= $poLineItems[OnOrder] ?></td>
<td><?= $poLineItems[OnHand] ?></td>
<td><input type="text" size="7" maxlength="6" name="<?php echo
'amtReceived_'.$poLineItems[VItemID]; ?>" value="" /></td>
<td>
<select name="<?php echo 'location_'.$poLineItems[VItemID]; ?>">
<?php
$stmt2 = "SELECT DISTINCT City, Zip FROM shipto WHERE CompanyID
= 169";
$result2 = mysql_query($stmt2);
while($rowDD = mysql_fetch_row($result2)) {
if($rowDD[0] == 'Rosemont') {
echo '<option value="'.$rowDD[0].'" selected>'.
$rowDD[0].', '.$rowDD[1].'</option>';
} else {
echo '<option value="'.$rowDD[0].'">'.$rowDD[0].', '.
$rowDD[1].'</option>';
}
}
?>
</select>
</td>
</tr>
<?php
}
?>
</table>
<p><input type="submit" value="Receive Items" method="POST" /></p>
<?php
} else {
?>
<p><div class="nogo">No items found for PO number <?=
$receive_ponum ?> </div><br />
<input type="button" value="<< Go Back <<"
onclick="history.back()" />
</p>
<?php
}
?>
Thanks for any help whatsoever......
Gene
my form contains only a positive integer. I know that this is fairly
simple if the form contains only one element to be validated; but, a
much bigger challenge ( to me anyway, that's why I'm coming to the
pros! ) when I don't know exactly how many fields may appear on the
form as it is dynamically generated based upon the number of line
items to be received on a purchase order. (i.e. if there are 10 items
to receive in; I will have 10 text fields to enter "quantity received"
into. Obviously, I want to be sure that only a positive integer is
accepted into these fields.
I apologize for pasting in SO MUCH of my code, but it gives you the
insight as to how my form elements are getting named...
The field I'm needing to validate is referenced in the code below as:
<td><input type="text" size="7" maxlength="6" name="<?php echo
'amtReceived_'.$poLineItems[VItemID]; ?>" value="" /></td>
Here is the code that generates the dynamic number of table rows/form
elements:
<?php
while ($poLineItems = mysql_fetch_assoc($result)) {
?>
<tr class="lineitem">
<td><?= $poLineItems[VItemID] ?></td>
<td align="left"><?= $poLineItems[CDescription] ?></td>" /></td>
<td><?= $poLineItems[OnOrder] ?></td>
<td><?= $poLineItems[OnHand] ?></td>
<td><input type="text" size="7" maxlength="6" name="<?php echo
'amtReceived_'.$poLineItems[VItemID]; ?>" value="" /></td>
<td>
<select name="<?php echo 'location_'.$poLineItems[VItemID]; ?>">
<?php
$stmt2 = "SELECT DISTINCT City, Zip FROM shipto WHERE CompanyID
= 169";
$result2 = mysql_query($stmt2);
while($rowDD = mysql_fetch_row($result2)) {
if($rowDD[0] == 'Rosemont') {
echo '<option value="'.$rowDD[0].'" selected>'.
$rowDD[0].', '.$rowDD[1].'</option>';
} else {
echo '<option value="'.$rowDD[0].'">'.$rowDD[0].', '.
$rowDD[1].'</option>';
}
}
?>
</select>
</td>
</tr>
<?php
}
?>
</table>
<p><input type="submit" value="Receive Items" method="POST" /></p>
<?php
} else {
?>
<p><div class="nogo">No items found for PO number <?=
$receive_ponum ?> </div><br />
<input type="button" value="<< Go Back <<"
onclick="history.back()" />
</p>
<?php
}
?>
Thanks for any help whatsoever......
Gene