Re: posting form values doesn't work
| From: | �ystein H�land | Date: | Mon, 02 Sep 2002 15:49:48 +0000 |
| Subject: | Re: posting form values doesn't work | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-114934@lists.php.net to get a copy of this message | ||
Yes, you were right. Now a natural question. WHY? I don't understand your
explanation, since I thought it was equal, getting a field value using
document.answerform.name.value in javascript AND the variable $name in php.
I still use php in the location.href-part (it is as follows, the other was
faked: location.href=groups/<?php echo $formname; ?>answer.php
This opens the file groups/collectanswer.php.
So, why does it work some time mixing javascript and php, and not every
time?
"Erwin" <erwin@isiz.com> skrev i meddelandet
news:20020902095942.62615.qmail@pb1.pair.com...
> ØYstein HåLand wrote:
> > This is my form:
> > <FORM NAME="answerform" METHOD=POST>
> > Your name:<BR><INPUT TYPE=TEXT NAME="name" SIZE=20>
> > Group:<BR><INPUT TYPE=TEXT NAME="group"
> > SIZE=8>
> > <INPUT TYPE=BUTTON VALUE=" OK!"
> > onClick="Javascript:validate(this);"> </FORM>
> >
> > and the function validate:
> > function validate() {
>
> [ CUT Javascript code ]
>
> > location.href='groups/collect_answer.php?name=<?php echo $name;
> > ?>&group=<?php echo $group; ?>';
>
> [ CUT Javascript code ]
>
> At first I thought is was JavaScript/HTML code, but I can see a little bit
> PHP now ;-))
> The reason that it doens't work is simple. The variables are only
available
> AFTER posting the form. Not during validation!
> You should just use Javascript to fill in the name and group into the URL.
>
> Grtz Erwin
>
>