> From: "Hawkes, Richard" <[EMAIL PROTECTED]>
> 
> Just spent far too long trying to figure out how to do this, so I thought I'd
> pass it on to you great guys, in case you need it for the future.
>  
> I used PHP to create multiple form rows, each one numbered:
> 
> <?
>     for ($i =1; $i <= 20; $i++) {
>         echo("<input type=text name=userId$i maxlength=5/><br/>");
>     }
> ?>

Use arrays. It'll make your life easier.

echo "<input type=\"text\" name=\"userId[$i]\" maxlength=\"5\"/><br />");

You can still reference the element in Javascript, just "by name" or whatever you call 
it. 

form.element['userId[1]'] (or something like that).

You show a Javascript validation. Remember that this is easily bypassed so you also 
need to validate the numbers on the PHP side. 

<?php
foreach($_POST['inputId'] as $id)
{
  if(!is_numeric($id))
  { echo "$id is invalid!"; }
}
?>

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to