Fields showing according to quantity selected

Basically I have a form field “quantity”
I need fields to be shown below this on the same page depending on the quantity…
i.e
quantity = 2 (this wil be a drop down on the form, the below should appear when selected)
staffno = staff department =
staffno = staff department =

if quantity = 4
staffno = staff department =
staffno = staff department =
staffno = staff department =
staffno = staff department =

Any help will be appreciated. I would need to submit the vallues to my database after.

thanks

Hi,
You could use a for() loop.
Example:

$quantity = 4;
for($i=0; $i<$quantity; $i++) {
  echo '<br> staffno = staff department = ';
}

Thanks… this is good but dont seem to work with tables… or am i doing something wrong…

i need it to create fields underneath… so if its four it should create 4 rows with a unique field in each one… someone mentioned ajax but im not sure exactly what i am looking for.