Re: determine number of entries Options (2)
- From: ZeldorBlat <zeldorblat@xxxxxxxxx>
- Date: Thu, 31 Jan 2008 06:04:03 -0800 (PST)
On Jan 31, 8:20 am, question....@xxxxxxxxxxx wrote:
This is a followup to a previous question.
I have a form with a series of sequentially named input controls
<input type='text' name='IngQty1'
onChange='javascript:saveValue(1,this.value)'>
<input type='text' name='IngQty2'
onChange='javascript:saveValue(2,this.value)'>
<input type='text' name='IngQty3'
onChange='javascript:saveValue(3,this.value)'>
...
I am trying to count the number of instances of inputs IngQty# and
also loop through the values.
In a response (seehttp://groups.google.com/group/php.general/browse_thread/thread/fee55...)
I got previously I was given the following
foreach($_SERVER['POST']['foo'] as $key => $value) {
//do something with each one
}
count($_SERVER['POST']['IngQty'])
but it doesn't work (I should rephrase that and say I can't get it to
work).
The for each generates a "Warning: Invalid argument supplied for
foreach()" and the count always returns a value of 0.
Could someone help me get these functional.
Thank you for the help!
QB
If what you've got above is what you're using I wouldn't expect it to
work. You still have your form elements named IngQty1, IngQty2, etc.
You need to use IngQty[1], IngQty[2], etc. Then, your foreach should
look something like this:
foreach($_SERVER['POST']['IngQty'] as $key => $value)
Of course, if your form is using GET it needs to be $_SERVER['GET']
['IngQty'].
.
- Follow-Ups:
- Re: determine number of entries Options (2)
- From: question . boy
- Re: determine number of entries Options (2)
- References:
- determine number of entries Options (2)
- From: question . boy
- determine number of entries Options (2)
- Prev by Date: Re: [PHP] Another question about functions...
- Next by Date: Re: [PHP] PEAR website and MSIE 6
- Previous by thread: determine number of entries Options (2)
- Next by thread: Re: determine number of entries Options (2)
- Index(es):