[PHP] [arrays] reading from a form.

2002-06-13 Thread Àlex Camps

I have a example.html
---
script
function add()
{
 var res=0;
 for(x=0;x3;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=1br
 input type=text name=text value=2br
 input type=text name=text value=3br
 input type=text name=result value=0br
 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







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




Re: [PHP] [arrays] reading from a form.

2002-06-13 Thread Stuart Dallas

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;x3;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=1br
  input type=text name=text value=2br
  input type=text name=text value=3br
  input type=text name=result value=0br
  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


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