Re: form variables before forms are submitted

From: Date: Thu, 20 Jul 2000 23:18:53 +0000
Subject: Re: form variables before forms are submitted
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-7490@lists.php.net to get a copy of this message
On Thu, 20 Jul 2000, Russell Uman wrote: > is there anyway i can access the values of form elements using php before i > submit the form (like javascript?) > > lets say i have > > <input type='text' name='text'> > <input type='hidden' value='$text2'> > > and i want $text2 to be some thing created from the value of the first > input. > > is there anyway to make javascript and php work together? i'm thinking > > <form onsubmit="phpfunction()"> > > or are the values of the inputs available to php in some other way? > > thanks! This sort of thing has come up several times in the last week, so it may be useful to go back and read through the list archives. Several folks have brought up good suggestions on the general topic. (Actually.. Are PHP-General, PHP-DB, etc even being archived anywhere yet? I'm fairly certain Geocrawler isn't doing them...) In short, this can't be done because PHP isn't aware of form variables until after the form has been submitted. PHP is a server-side language, and as such, cannont interact with JavaScript. <form onSubmit="phpfunction()"> wouldn't work, because JavaScript has no reason to know phpfunction() exists. <input type='text' name='text'> <input type='hidden' value='$text2'> You could probably have JavaScript derive $text2 from the previous field, but PHP definitely won't be able to do it, for the reasons mentioned above. Matt

« previous php.general (#7490) next »