[PHP] Re: PHP, Javascript, and Forms
Hello, on 05/30/2006 11:03 PM Beauford said the following: > I have a form with about 20 fields in it and have two drop down menus in > which the second one changes depending on the previous one. This is done > with a javascript which reloads the page. > > The problem with this is that everything the user has put in so far gets > erased when the page reloads. I am using PHP sessions, but at this point > these fields are not saved yet. > > Is there a way to do this using sessions, or some other PHP function. All > the javascript I've looked at reloads the page. > > This also screws up my validation routines. You may want to try this forms generation and validation class. It provides means to do exactly what you want. It comes with several plug-ins that simplify the implementation of controls like you want. There is one plug-in that can link 2 or more select inputs, on which one switches its group of options when another changes the currently selected value. The new group of options can be loaded from a static array or dynamically connecting to the server via AJAX and executing some task that gets the new set options depending on the new linked select value. It comes also with several variants of the plugin that query databases to retrieve the new sets of options. Here is a screenshot of a form using the static array version: http://www.phpclasses.org/browse/view/html/file/9879/name/test_linked_select_page.html There is also a more generic plug-in form submitting the form using AJAX. This means that you can submit the form without reloading the page. In response you can tell the class to make the current browser page be updated arbitrarily. There is now even a plug-in to integrate with Google Maps, but that is anothe story: The class and all plug-ins are available here. See the dependent classes too for more third party plug-ins: http://www.phpclasses.org/formsgeneration -- Regards, Manuel Lemos Metastorage - Data object relational mapping layer generator http://www.metastorage.net/ PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP & JavaScript
Angelo Zanetti wrote: Daniel Orner wrote: Jay Blanchard wrote: Can they play nicely together? For instance I have a small JavaScript sniplet that will check certain checkboxes if a radio button is selected. Since I have a fair amount of checkboxes I want to put them in an array all their own so I use the XHTML syntax w/brackets; Suddenly JavaScript doesn't care for the object and throws an error (take the brackets out and it works fine for JS, but PHP cannot see all of the values). I have Googled for this but think that my search term(s) are failing me because the condition is hard to describe. Would someone please point me in the right direction? Thanks! What kind of error does it throw? What function are you using to access the object? --Daniel if u declare is like name="list37" doesnt PHP get that as an array even though it doesnt have the square brackets? Nope. Test it. -- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP & JavaScript
Could you not use an id for the object as well as a name?
[PHP] Re: PHP & JavaScript
function checkAll(field){ for (i = 0; i < field.length; i++){ field[i].checked = true; } } 'length' is null or not an object Where is this being called from? Checkboxes don't have a "length"... if u declare is like name="list37" doesnt PHP get that as an array even though it doesnt have the square brackets? No, you need the square brackets to return an array of values. Otherwise you'll only get the first one. --Daniel Jay Blanchard wrote: [el snipo] For instance I have a small JavaScript sniplet that will check certain checkboxes if a radio button is selected. Since I have a fair amount of checkboxes I want to put them in an array all their own so I use the XHTML syntax w/brackets; Suddenly JavaScript doesn't care for the object and throws an error (take the brackets out and it works fine for JS, but PHP cannot see all of the values). I have Googled for this but think that my search term(s) are failing me because the condition is hard to describe. Would someone please point me in the right direction? Thanks! What kind of error does it throw? What function are you using to access the object? [/el snipo] function checkAll(field){ for (i = 0; i < field.length; i++){ field[i].checked = true; } } 'length' is null or not an object -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: PHP & JavaScript
Daniel Orner wrote: Jay Blanchard wrote: Can they play nicely together? For instance I have a small JavaScript sniplet that will check certain checkboxes if a radio button is selected. Since I have a fair amount of checkboxes I want to put them in an array all their own so I use the XHTML syntax w/brackets; Suddenly JavaScript doesn't care for the object and throws an error (take the brackets out and it works fine for JS, but PHP cannot see all of the values). I have Googled for this but think that my search term(s) are failing me because the condition is hard to describe. Would someone please point me in the right direction? Thanks! What kind of error does it throw? What function are you using to access the object? --Daniel if u declare is like name="list37" doesnt PHP get that as an array even though it doesnt have the square brackets? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] RE: PHP & JavaScript
[el snipo] > For instance I have a small JavaScript sniplet that will check certain > checkboxes if a radio button is selected. Since I have a fair amount of > checkboxes I want to put them in an array all their own so I use the > XHTML syntax w/brackets; > > > > Suddenly JavaScript doesn't care for the object and throws an error > (take the brackets out and it works fine for JS, but PHP cannot see all > of the values). I have Googled for this but think that my search term(s) > are failing me because the condition is hard to describe. Would someone > please point me in the right direction? > > Thanks! What kind of error does it throw? What function are you using to access the object? [/el snipo] function checkAll(field){ for (i = 0; i < field.length; i++){ field[i].checked = true; } } 'length' is null or not an object -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP & JavaScript
Jay Blanchard wrote: Can they play nicely together? For instance I have a small JavaScript sniplet that will check certain checkboxes if a radio button is selected. Since I have a fair amount of checkboxes I want to put them in an array all their own so I use the XHTML syntax w/brackets; Suddenly JavaScript doesn't care for the object and throws an error (take the brackets out and it works fine for JS, but PHP cannot see all of the values). I have Googled for this but think that my search term(s) are failing me because the condition is hard to describe. Would someone please point me in the right direction? Thanks! What kind of error does it throw? What function are you using to access the object? --Daniel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP / JavaScript integration
Mário Gamito wrote: > Hi, > > I'm trying to integrate some JavaScript functions in PHP, but so far, no > good :( > ... > > How can i do this ? > How to tell PHP, that def(word) is a JS function in js.php file ? > I've tried include ('js.php'), etc., but got no results :( > > Any help would be apreciated. > Well... you can easily send the Javascript function to the browser with something like: $js = file_get_contents('js.php'); echo $js; HOWEVER... there isn't really a way for PHP to use that Javascript function. PHP works on the *server* side, whereas Javascript works on the *client* side. Now back in PHP4 there was an extension for using Java with the PHP interpreter, but AFAIK that extension has not been adapted for PHP5 yet. And PHP5's object model is *closer* to the Java model. So my best guess is that whoever wrote that extension decided that it was more trouble than it was worth to get Java working within PHP5? Definitely worth your time to read this: http://php.net/manual/en/ref.java.php -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-general&w=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHP&submitform=Find+search+plugins signature.asc Description: OpenPGP digital signature
[PHP] Re: PHP & Javascript compatibilty
I'm developing a WYSIWYG editor using PHP and Javascript (for COM). However, I start having problems when I try to display the page using the .php extension. The Javascript is not working. However, when I save it to HTML, it worked fine. Can anyone please help me? Why is this so? What can I do to get Javascript working with PHP with ease? Any articles on this? Thanks a lot... again. :) If you show me some code I can look at, I might be able to assist you. You should have no trouble executing JS on a file with a .php extension, so long as it is incorporated into HTML. -- Kyle Gibson admin(at)frozenonline.com http://www.frozenonline.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php & JavaScript
Javascript is client side and is not parsed by the server at all If you are generating javascript with PHP, and it is in an external file, it still needs a .php extension Can you be more specific to the problem, paste some code? "Luis Miguel N. Tavora" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hi there. > > I've tried to include a simple javascript in a .php file, > but couldn't get it to work. > > Actually not even the php code worked at all... > > Is there any specific configuration flag that needs to be > set up in the Apache server so that the javascripts work > correctly? > > Thanks in advance > > Luis > > PS- Btw, I use an Apache server on a RH72 machine > > > > -- >Luis Miguel N. Távora >[EMAIL PROTECTED] > > Message sent via Sylpheed > sylpheed-claws.sourceforge.net > -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PhP & Javascript Mixed Repost Fields
sorry the correct code is: in fooa.php for each textfield so, when you come back from foob.php if a $field !empty the respective textfiel will have a value in html form; -- Best regards, George Nicolae IT Manager ___ PaginiWeb.com - Professional Web Design www.PaginiWeb.com "Simos Varelakis" <[EMAIL PROTECTED]> wrote in message 000401c1d9a2$afd6bde0$9b00a8c0@simos">news:000401c1d9a2$afd6bde0$9b00a8c0@simos... Here is a problem :-) A php post form fooa.php Submit all form fields to a page foob.php Page foob.php do some mysql db check and in one condition I want to Return to fooa.php without losing any field value... I made this from foob.php with header:("location:fooa.php?field1=$field1&field2=$field2.etc") But this is more complex esspecially when in fooa.php there are radio buttons + checkboxes. I thing that if I could with Javascript in foob.php create an (invisble) form and take all posted fields from Fooa.php And resubmit it with form.submit method to fooa.php I will have best results But I dont know how to do this since I am a begginer.. Anyone can help please send me an email Thanks in advnace for your time & help and excuse me if is off topic Best Regads simos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PhP & Javascript Mixed Repost Fields
in fooa.php for each textfield so, when you come back from foob.php if a $field !empty the respective textfiel will have a value in html form; -- Best regards, George Nicolae IT Manager ___ PaginiWeb.com - Professional Web Design www.PaginiWeb.com "Simos Varelakis" <[EMAIL PROTECTED]> wrote in message 000401c1d9a2$afd6bde0$9b00a8c0@simos">news:000401c1d9a2$afd6bde0$9b00a8c0@simos... Here is a problem :-) A php post form fooa.php Submit all form fields to a page foob.php Page foob.php do some mysql db check and in one condition I want to Return to fooa.php without losing any field value... I made this from foob.php with header:("location:fooa.php?field1=$field1&field2=$field2.etc") But this is more complex esspecially when in fooa.php there are radio buttons + checkboxes. I thing that if I could with Javascript in foob.php create an (invisble) form and take all posted fields from Fooa.php And resubmit it with form.submit method to fooa.php I will have best results But I dont know how to do this since I am a begginer.. Anyone can help please send me an email Thanks in advnace for your time & help and excuse me if is off topic Best Regads simos -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP-JavaScript
Mëòv îçîÎ òsyïn wrote: > Is it posible to get values from javascript to PHP? Without having to post > the variables.. > > Thanks //Mårten > > _ > Chatta med vänner online, prova MSN Messenger: http://messenger.msn.se I'm not quite sure what you are trying to do. Javascript is executing on the browser, php executes on the server, therefore to get anything from the Javascript to php your browser will have to communicate with the server via a request. This could be a form submission, which might be a POST or a GET. Alternatively, it is also possible to send data to a php script via a url e.g. myscript.php?myfield=myvalue. That means that wherever you can get Javascript to cause the browser to issue a request for a url, if the target at the other end is a php script then you can send data to that script. I don't know what you are trying to do, and this is all pretty obscure stuff, but you could for example put a hidden 1x1 image in the page and then get your Javascript to change the location of this image to be a php script with a variable passed on e.g. something like dummyimage.location = "/myscript.php?myfield="+myjsvalue; As long as you get the php to send back another empty 1x1 pixel, e.g. via a header("Location: 1x1pixel.gif"), then your browser page will stay the same as ever. As it happens I do sometimes do just this in Javascript but it's to get a new dynamic image back without reloading a page. Go to http://tandridge.cpfc.co.uk/tables/0222/graph/2/d7 and then select something different in the Team 1 or Team 2 selection box, and watch the graph at the bottom of the page to see this happen. In the source look for the Javascript function chteam_id() to see how it's done here. Good luck, George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: PHP-JavaScript
the only way php is going to know about a variable is if the server the script is on is sent the variable, the normal way of doing that is through posting/getting a page/script Martin -Original Message- From: Andrew V. Romero [mailto:[EMAIL PROTECTED]] Sent: Monday, January 21, 2002 2:11 PM To: [EMAIL PROTECTED]; =?iso-8859-1?Q?M=EB=F2v=20=EE=89=E7=EE=CE=20=F2sy=EFn?[EMAIL PROTECTED] Subject: [PHP] Re: PHP-JavaScript Would it be possible to have javascript insert a hidden input tag in the html and then php could pick it up? Just an idea, Andy Mëòv î?çîÎ òsyïn wrote: > Is it posible to get values from javascript to PHP? Without having to post > the variables.. > > Thanks //Mårten > > _ > Chatta med vänner online, prova MSN Messenger: http://messenger.msn.se -- 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] Re: PHP-JavaScript
Would it be possible to have javascript insert a hidden input tag in the html and then php could pick it up? Just an idea, Andy Mëòv îçîÎ òsyïn wrote: > Is it posible to get values from javascript to PHP? Without having to post > the variables.. > > Thanks //Mårten > > _ > Chatta med vänner online, prova MSN Messenger: http://messenger.msn.se -- 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]