Re: javascript and php

From: Date: Tue, 16 Jan 2001 09:34:44 +0000
Subject: Re: javascript and php
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-34783@lists.php.net to get a copy of this message
In general: We made a script which did this, however a bit limited because of the client/server-problems mentioned. The script is part of a registration-form, and pick out a city based on the zip entered. We didn't want the list of zipcodes and cities in JS since it would be quite huge. Don't remember the excacts but in general: (simplified model) <form name=oFrm> <input name=zip onBlur='fetch();'><input name=city> </form> Fetch() is a function that opens a new pop-up window at 50x50px, and set the url-property of this window using JS (ex:) var strURL = "find_city.php?zip=" + document.oFrm.zip.value; The find_city.php script recieves the zip in a get-var, and can connect to mysql and retrieve the city etc. and closes itself. find_city then outputs JS (ex): <script> opener.document.oFrm.city.value = "$the_right_city"; self.close(); </script> The "drawbacks" here is a window flashing a short second or so... You can make this thing run queries or whatever... Wrote the above from memory, so the syntax might be a bit of, but the flow is the same. have a nice day! -Jørg V. Bryne ----- Original Message ----- From: "Patrice ROTH" <proth@corys.fr> To: <php-general@lists.php.net> Sent: Tuesday, January 16, 2001 10:04 AM Subject: [PHP] javascript and php > It is easy to generate javascript through php,but how to call php through > javascript. > In fact, I'd like to update some form fields according to events on other > fields. I can do this using javascript, but the values should be readed in a > MySql database. > > Thank's > Patrice > ----- Original Message ----- From: "Soeren Staun-Pedersen" <staun@itcampus.dk> To: "Patrice ROTH" <proth@corys.fr> Cc: <php-general@lists.php.net> Sent: Tuesday, January 16, 2001 10:08 AM Subject: Re: [PHP] javascript and php > > It is easy to generate javascript through php,but how to call php through > > javascript. > > In fact, I'd like to update some form fields according to events on other > > fields. I can do this using javascript, but the values should be readed in a > > MySql database. > > You're in a serverside, clientside problem. You want the client to execute > the PHP code, which it cannot. If you want to update the form fields with > some other data, you have to provide the page you sent to the client with > all the needed data beforehand. > > Regards, > > Soeren Staun-Pedersen - staun@netwarriors.org > ------ > "The internet is full, beat it" > - Me. > > > > -- > 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 >

« previous php.general (#34783) next »