Re: [arrays] reading from a form.
| From: | Stuart Dallas | Date: | Thu, 13 Jun 2002 17:48:27 +0000 |
| Subject: | Re: [arrays] reading from a form. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-102011@lists.php.net to get a copy of this message | ||
On Thursday, June 13, 2002 at 6:38:10 PM, you wrote:
> I have a example.html
> -------------------------------
> <script>
> function add()
> {
> var res=0;
> for(x=0;x<3;x++)res=res+parseFloat(example.text[x].value);
> example.result.value=res;
> }
> </script>
> <html>
> <form name="example" action="show.php">
> <input type="text" name="text" value="1"><br>
> <input type="text" name="text" value="2"><br>
> <input type="text" name="text" value="3"><br>
> <input type="text" name="result" value="0"><br>
> <input type="button" value="add" OnClick="add()">
> <input type="submit" value="show">
> </form>
> </html>
> -------------------------------
> and show.php
> -------------------------------
> <html>
> <?
> echo $text[0]."+".$text[1]."+".$text[2]."=";
> echo $result;
?>>
> </html>
> PHP return the error:
> Notice: Uninitialized string offset: 1 in show.php on line 4
> How could I know the values of the text? without modify example.html
The easiest way would be to modify example.html and change each instance of
name="text" to name="text[]". However, since you say you cannot do that, try
echoing $_SERVER['QUERY_STRING']. If that contains all 3 then you can parse
that to get the values out.
--
Stuart