Page 1 of 1

can I assign a number to the name value in a text field?

Posted: Wed Oct 12, 2005 5:24 pm
by michlcamp
I'm using a while loop to query products from a table to create an orderform. Works fine.
The products and descriptions "echo" on the page to create the orderform and a text field named "qty" for quantity ordered is written for each product in the table. This is where the customer puts in how many of each product they want to buy.

It writes like this:

Code: Select all

while..blah blah blah..

echo "$product - Qty: <input type=\"text\" name=\"qty\" size=2><br>";
My question:
How do I assign ascending numbers to each "qty" field?
I'd like the output to be:

product 1 : <input type=\"text\" name=\"qty1\" size=2><br>
product 2 : <input type=\"text\" name=\"qty2\" size=2><br>
product 3 : <input type=\"text\" name=\"qty3\" size=2><br>

and so on..

the products part is already working, I'm just after how to write the code that will add a number to the "qty" field for each.

Thanks in advance.
mc

Posted: Wed Oct 12, 2005 5:31 pm
by pickle
You can certainly put numbers in there, either before, after, or instead of 'qty'. However, having a field like '001qty' will not validate XHTML 1.0. It'll still work fine, it just won't validate.

got it

Posted: Wed Oct 12, 2005 5:44 pm
by michlcamp
got it..dumb question