Re: php & javascript
| From: | sarahana | Date: | Wed, 14 Jun 2000 07:04:14 +0000 |
| Subject: | Re: php & javascript | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1814@lists.php.net to get a copy of this message | ||
Actually, what I was tActually, I was trying to allow multiple selection in a
select menu, so I need to get all the selected options... can I do this
WITHOUT using javascript?
gracias.
burk@pobox.com wrote:
> As other people have stated, it can't be done "smoothly", although they
> told you how to move a php variable to javascript. To move a javascript to
> php, the only way I have found is to use javascript to set the value of a
> form element and submit it. Something like
>
> echo "
> <script language=javascript>
> function passvar (MyVar) {
> document.MyForm.elements[\"MyHidden\"].value=var;
> document.MyForm.submit();
> }
> </script>
> ";
>
> // and then in the body of the page
>
> echo "
> <form method=post action=\another.php\" name=\"MyForm\">
> <input type=hidden name=\"MyHidden\" value=\"\">
> </form>
> ";
>
> // and then when you need to move the value of the javascript variable
> // you call
>
> echo "
> <input type=button value=\"Move the Variable\"
> onClick=\"passvar(MyVar)\">
> ";
>
> // now in the receiving page $MyHidden is var
>
> This will work If And Only If
> The client has javascript turned on AND
> The client's browser supports javascript AND
> You can tolerate a form submit to accomplish this
>
> All in all, you should save javascript for when it's not important, or
> when you really need it, and then you should test for it, or warn the user
> that they need it.
>
> HTH,
> -burk
>
> On Tue, 13 Jun 2000, sarahana wrote:
>
> > Hi, I was wondering:
> >
> > How would you assign the value of a javascript variable to a php
> > variable?
> >
> > gracias.
> >
> >
> >
>
> --
> burk@pobox.com
> Linux File Managers: http://www.pobox.com/~burk/linuxfile.html
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net