Re: [PHP] Javascript and Php
On Thursday 01 March 2001 13:19, you wrote: > I'd like to include an inc file once a button id cliked! You can only request a new page. Period. PHP runs on the server, button clicks are evaluated on the client (browser). -- Christian Reiniger LGDC Webmaster (http://sunsite.dk/lgdc/) The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence. - Edsger W. Dijkstra -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
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 - [EMAIL PROTECTED] -- "The internet is full, beat it" - Me. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] javascript and php
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) 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): opener.document.oFrm.city.value = "$the_right_city"; self.close(); 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" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> 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" <[EMAIL PROTECTED]> To: "Patrice ROTH" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> 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 - [EMAIL PROTECTED] > -- > "The internet is full, beat it" > - Me. > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] JavaScript and PHP
Assuming your page is called something like myPageWithScripts.php, do something like this: < html > < head > < script language="javascript" type="text/javascript" > < !-- //Hide function myFunction { alert("My PHP variable value is "); } // --> < /head > ...and so on. Jordan wrote: > Hey all, > > Just a quick question...how would you pass a PHP variable to a JavaScript > function? > > -Jordan > > > > -- Sliante, Richard S. Crawford mailto:[EMAIL PROTECTED] http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Yahoo!: rscrawford MSN: [EMAIL PROTECTED] "When you have lost the ability to laugh at yourself, you have lost the ability to think straight." --Clarence Darrow "Push the button, Max!" -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Javascript and PHP
[EMAIL PROTECTED] wrote: Well the question is: i want to know how can i make to insert into the $_GET or $_POST arrays, an entry with a value from javascript. All the php processing (on the server) is complete before the javascript processing (on the client) commences, so you would need to submit to a new location with JS giving parameters in the url. These would then appear in the $_GET array for the location you submit to. HTH Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Javascript and PHP
Hi, Wednesday, November 6, 2002, 2:52:31 AM, you wrote: vaue> Hi. I'm not sure if is here where i have to ask this, but, if it's vaue> not i hope you say to me :D. vaue> Well the question is: i want to know how can i make to insert into vaue> the $_GET or $_POST arrays, an entry with a value from javascript. vaue> Thanks This is a post method: function doit(){ testval = "Hello"; document.form1.result.value = testval; document.form1.submit(); } should end up with $_POST['result'] = Hello -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] javascript and PHP
since php runs on the server, not on the client, you have to pass the value of data back to the server. Normally, this is done via a GET or a POST from a form or by building a URL and using javascript to load it. (i.e. document.location = 'http://myserver.com/mypage.php?data=Hello%20World';) Then your PHP script can execute and see the value of $_GET['data'] HTH, Cal * * Cal Evans * Journeyman Programmer * Techno-Mage * http://www.calevans.com * -Original Message- From: Steve Buehler [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 10:30 AM To: [EMAIL PROTECTED] Subject: [PHP] javascript and PHP Does anybody know of a good/short tutorial about passing variables from JavaScript to/from PHP? For example, how to do the following: data = "hello world"; "; ?> The above might at least give me a clue. Just a note. I really know nothing to speak of about JavaScript. Thanks in Advance Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] javascript and PHP
All you can do is use PHP to print out Javascript code. var something; something = '=$data?>'; etc...It's no different than using PHP to print out HTML code. Now, if you want to get that Javascript variable "something" sent back to PHP, you have to assign it to a form element or tack it onto a URL. ---John Holmes... - Original Message - From: "Steve Buehler" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, April 29, 2002 11:29 AM Subject: [PHP] javascript and PHP > Does anybody know of a good/short tutorial about passing variables from > JavaScript to/from PHP? For example, how to do the following: > > > > > data = "hello world"; > > > > echo "$data"; > ?> > > > > The above might at least give me a clue. Just a note. I really know > nothing to speak of about JavaScript. > > Thanks in Advance > Steve > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] javascript and PHP
This is what I do in one of my programs. I set hidden values in my HTML and then JS can access them, change them, and then when the form is submitted (JS can do that too if you want it to be automatic) the PHP reads in the hidden values. -Natalie -Original Message- From: 1LT John W. Holmes [mailto:[EMAIL PROTECTED]] Sent: Monday, April 29, 2002 11:40 AM To: [EMAIL PROTECTED]; Steve Buehler Subject: Re: [PHP] javascript and PHP All you can do is use PHP to print out Javascript code. var something; something = '<?=$data?>'; etc...It's no different than using PHP to print out HTML code. Now, if you want to get that Javascript variable "something" sent back to PHP, you have to assign it to a form element or tack it onto a URL. ---John Holmes... - Original Message - From: "Steve Buehler" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, April 29, 2002 11:29 AM Subject: [PHP] javascript and PHP > Does anybody know of a good/short tutorial about passing variables > from JavaScript to/from PHP? For example, how to do the following: > > > > > data = "hello world"; > > > > echo "$data"; > ?> > > > > The above might at least give me a clue. Just a note. I really know > nothing to speak of about JavaScript. > > Thanks in Advance > Steve > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Javascript and PHP??
Use header to start file download: http://www.php.net/manual/en/function.header.php Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com > -Original Message- > From: Joe Keilholz [mailto:[EMAIL PROTECTED]] > Sent: Thursday, April 04, 2002 1:12 AM > To: [EMAIL PROTECTED] > Subject: [PHP] Javascript and PHP?? > > Hello All! > > I think this is a pretty simple question. I have a file that I am writing > information to and when the process is complete, I am needing to send the > file to the user. In Javascript all I would need to do is window.open() and > the file would be sent to the user (it's a .csv file). How would I > accomplish this in PHP? Can I incorporate Javascript into my PHP code? If > so, how? > > Any help would be appreciated! > Thanks! > Joe Keilholz > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Javascript and PHP??
You can say something like: window.open("=$csv_filename?>", "target", "resizable,status,width=500,height=200"); On Wed, 3 Apr 2002, Joe Keilholz wrote: > Hello All! > > I think this is a pretty simple question. I have a file that I am writing > information to and when the process is complete, I am needing to send the > file to the user. In Javascript all I would need to do is window.open() and > the file would be sent to the user (it's a .csv file). How would I > accomplish this in PHP? Can I incorporate Javascript into my PHP code? If > so, how? > > Any help would be appreciated! > Thanks! > Joe Keilholz > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Javascript and PHP??
"Mikhail Avrekh" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > You can say something like: > > > > window.open("=$csv_filename?>", > "target", > "resizable,status,width=500,height=200"); > > > > > On Wed, 3 Apr 2002, Joe Keilholz wrote: > > > Hello All! > > > > I think this is a pretty simple question. I have a file that I am writing > > information to and when the process is complete, I am needing to send the > > file to the user. In Javascript all I would need to do is window.open() and > > the file would be sent to the user (it's a .csv file). How would I > > accomplish this in PHP? Can I incorporate Javascript into my PHP code? If > > so, how? > > > > Any help would be appreciated! > > Thanks! > > Joe Keilholz > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] JavaScript and PHP
On Wed, May 14, 2008 at 2:31 PM, Mário Gamito <[EMAIL PROTECTED]> wrote: > Hi, > > I have this HTML/JS page that switches images clicking on the radio buttons > and call template.php with the image ID as parameter: > http://portulan-online.net/einstein.html > > Now, I need to make it a PHP page, because it is going to receive a > parameter from the URL that calls it and pass it as is to template.php > > > So, einstein.php will be called with a parameter (satellite): > http://portulan-online.net/einstein.php?satellite=123 > > After that, in einstein.php, I do: > > $satellite = $_REQUEST['satellite']; > > Next thing, I need the action in the JavaScript to be, for example: > http://portulan-online.net/template.php?id=3&satellite=123 > > What I don't know is how to mix the "PHP variable" satellite with the image > ID here: > document.getElementById('image1').src = " > http://portulan-online.net/einstein-"; + ID + ".png"; > > I've tried putting einstein.php all inside an "echo", but the radio buttons > and the submit button stopped working. > > Does anyone knows how to do this ? > > Any help would be appreciated. > > Warm Regards, > Mário Gamito > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > document.getElementById('image1').src = " http://portulan-online.net/einstein-"; + + ".png"; You could do that. Also, I'd suggest using $_GET instead of $_REQUEST. Request works,b ut it is very broad. $_GET is more specific/secure. -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month. Reseller plans and Dedicated servers available. "Build a man a fire, and he will be warm for the rest of the day. Light a man on fire, and will be warm for the rest of his life."
Re: [PHP] JavaScript and PHP
At 7:31 PM +0100 5/14/08, Mário Gamito wrote: Hi, I have this HTML/JS page that switches images clicking on the radio buttons and call template.php with the image ID as parameter: http://portulan-online.net/einstein.html Now, I need to make it a PHP page, because it is going to receive a parameter from the URL that calls it and pass it as is to template.php Mário: The key here to remember is that javascript uses ID and php uses NAME for inputs. So, if you put your variables in that form and they will work between javascript and php. Such as: onclick="javascript:GetImage(this);">Einstein 2 Note the change of "this" in your js call -- you can do that and not have to provide the number. Also put in an action="whatever" into your form and collect the selection via $_POST['rad']; That will do what you want. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] JavaScript and PHP
On 14 May 2008 21:21, tedd advised: > At 7:31 PM +0100 5/14/08, Mário Gamito wrote: >> Hi, >> >> I have this HTML/JS page that switches images >> clicking on the radio buttons and call >> template.php with the image ID as parameter: >> http://portulan-online.net/einstein.html >> >> Now, I need to make it a PHP page, because it is >> going to receive a parameter from the URL that >> calls it and pass it as is to template.php > > Mário: > > The key here to remember is that javascript uses > ID and php uses NAME for inputs. That's incorrect. A form will function perfectly well with only name= attributes, and no ids, and it's quite possible for JavaScript to address the form elements using only the names (in fact, it's easier than via the ids as there's a short syntax for it!). CSS and the DOM, however, use the ids as primary identifier, so use of either of those may demand the presence of ids. Cheers! Mike -- Mike Ford, Electronic Information Developer, C507, Leeds Metropolitan University, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] JavaScript and PHP
> -Original Message- 8< snip! > That's incorrect. A form will function perfectly well with only name= > attributes, and no ids, and it's quite possible for JavaScript to > address the form elements using only the names (in fact, it's easier > than via the ids as there's a short syntax for it!). > > CSS and the DOM, however, use the ids as primary identifier, so use of > either of those may demand the presence of ids. 8< snip! True, you can access an input named "myInput" in a form named "myForm" by simply writing: document.myForm.myInput.value = "Hello!"; BUT... for CSS, it's also quite easy to reference something by name: [name="myElement"] { color: blue; font-size: 10pt; } Todd Boyd Web Programmer -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] JavaScript and PHP
On 16 May 2008 16:12, Boyd, Todd M. advised: >> -Original Message- > > 8< snip! > >> That's incorrect. A form will function perfectly well with only name= >> attributes, and no ids, and it's quite possible for JavaScript to >> address the form elements using only the names (in fact, it's easier >> than via the ids as there's a short syntax for it!). >> >> CSS and the DOM, however, use the ids as primary identifier, so use of >> either of those may demand the presence of ids. > > 8< snip! > > True, you can access an input named "myInput" in a form named "myForm" by > simply writing: > > document.myForm.myInput.value = "Hello!"; > > BUT... for CSS, it's also quite easy to reference something by name: > > [name="myElement"] > { > color: blue; > font-size: 10pt; > } Well, true -- hence the qualifiers in "*primary* identifier" and "*may* demand"! Cheers! Mike -- Mike Ford, Electronic Information Developer, C507, Leeds Metropolitan University, Civic Quarter Campus, Woodhouse Lane, LEEDS, LS1 3HE, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 812 4730 To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] JavaScript and PHP
At 4:01 PM +0100 5/16/08, Ford, Mike wrote: On 14 May 2008 21:21, tedd advised: At 7:31 PM +0100 5/14/08, Mário Gamito wrote: Hi, I have this HTML/JS page that switches images clicking on the radio buttons and call template.php with the image ID as parameter: http://portulan-online.net/einstein.html Now, I need to make it a PHP page, because it is going to receive a parameter from the URL that calls it and pass it as is to template.php Mário: The key here to remember is that javascript uses ID and php uses NAME for inputs. That's incorrect. A form will function perfectly well with only name= attributes, and no ids, and it's quite possible for JavaScript to address the form elements using only the names (in fact, it's easier than via the ids as there's a short syntax for it!). Incorrect or not, it works. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Javascript and php
On Sun, 7 Nov 2004 11:44:33 +0100, Reinhart Viane <[EMAIL PROTECTED]> wrote: > Hope some of you also work on sundays :) > > I have a little javascript which displays a images (with previous / next > thing) > Now, i populate the javascript array with an php array: > > > >