jasonc Posted February 26, 2006 Share Posted February 26, 2006 I have a form that is filled in and each part that has something done to it i want added to a database on my server, for that user.I have a onchange=update() in my form and this would then call the script to update the database.is this possible.or is there another way i can do this.i tried to use in the update.js filefunction update(){<?echo("hello");?>}just to see if anything happen, and it did not.how can i execute php while in a js file?is there another way to do this?thanks you in advance for your help.Jason Quote Link to comment https://forums.phpfreaks.com/topic/3636-execute-php-from-javascript/ Share on other sites More sharing options...
phpfreak101 Posted February 26, 2006 Share Posted February 26, 2006 php is executed on the server and then the code that is outputted by the php code, is added to your site's HTML. After a user views your website, the php has already been executed and the output writen to your site. If you need to pass information to a php file after the user has viewed your site you can set up a hidden or visible textbox form with HTML, and send the POST values (or the values of each form element after the user has 'posted' the form) to another php file. Set your form "action" to the next php file you want to pass the variables to, and then you can use $_POST['html form element name'] THis is your form element value. Quote Link to comment https://forums.phpfreaks.com/topic/3636-execute-php-from-javascript/#findComment-12608 Share on other sites More sharing options...
kenrbnsn Posted February 26, 2006 Share Posted February 26, 2006 You can now use the new(ish) AJAX techniques to do this. There is a forum on this site for AJAX questions along with a sister site [a href=\"http://www.ajaxfreaks.com/\" target=\"_blank\"]AJAXfreaks[/a].Ken Quote Link to comment https://forums.phpfreaks.com/topic/3636-execute-php-from-javascript/#findComment-12623 Share on other sites More sharing options...
jasonc Posted February 26, 2006 Author Share Posted February 26, 2006 my page has lots of options and i want to be sure that the selection are kept in case they lose their connection of what ever.each person has a login name and password.while they make their selection i want the database updated on each change, so that they can come back later to finish off, without having to full out everything from the start again.how else can i do this?ThanksJason Quote Link to comment https://forums.phpfreaks.com/topic/3636-execute-php-from-javascript/#findComment-12642 Share on other sites More sharing options...
hitman6003 Posted February 26, 2006 Share Posted February 26, 2006 Use javascript to store the values in a cookie.[a href=\"http://www.w3schools.com/js/js_cookies.asp\" target=\"_blank\"]http://www.w3schools.com/js/js_cookies.asp[/a]Then when they come back to the site, you should be able to retrieve the vars in either php or javascript. Quote Link to comment https://forums.phpfreaks.com/topic/3636-execute-php-from-javascript/#findComment-12650 Share on other sites More sharing options...
jasonc Posted February 26, 2006 Author Share Posted February 26, 2006 Hi,Thanks for a quick response.Yes i know i could use cookies, but want to make this as streamlined as possible.i know as i do myself, disable cookies from being stored on my pc, this is why i would like to have it stored in the database.how else can i do this?Jason Quote Link to comment https://forums.phpfreaks.com/topic/3636-execute-php-from-javascript/#findComment-12652 Share on other sites More sharing options...
hitman6003 Posted February 27, 2006 Share Posted February 27, 2006 Your only other option for storing each field as they are entered is ajax. Quote Link to comment https://forums.phpfreaks.com/topic/3636-execute-php-from-javascript/#findComment-12653 Share on other sites More sharing options...
jasonc Posted February 27, 2006 Author Share Posted February 27, 2006 [!--quoteo(post=349702:date=Feb 27 2006, 12:00 AM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Feb 27 2006, 12:00 AM) [snapback]349702[/snapback][/div][div class=\'quotemain\'][!--quotec--]Your only other option for storing each field as they are entered is ajax.[/quote]your say ajax, but what am i looking for?i have posted my question there.thanksJason Quote Link to comment https://forums.phpfreaks.com/topic/3636-execute-php-from-javascript/#findComment-12685 Share on other sites More sharing options...
tim_perrett Posted February 27, 2006 Share Posted February 27, 2006 AJAX it is, thats the only way you will do that....www.ajaxfreaks.comTim Perrett Quote Link to comment https://forums.phpfreaks.com/topic/3636-execute-php-from-javascript/#findComment-12693 Share on other sites More sharing options...
jasonc Posted February 27, 2006 Author Share Posted February 27, 2006 [!--quoteo(post=349788:date=Feb 27 2006, 09:53 AM:name=tim_perrett)--][div class=\'quotetop\']QUOTE(tim_perrett @ Feb 27 2006, 09:53 AM) [snapback]349788[/snapback][/div][div class=\'quotemain\'][!--quotec--]AJAX it is, thats the only way you will do that....www.ajaxfreaks.comTim Perrett[/quote]ajax is a forum with some help pages with scripts.what an i actually looking for on this site.a link would be helpfull to an idiot like me.i am not very bright! Quote Link to comment https://forums.phpfreaks.com/topic/3636-execute-php-from-javascript/#findComment-12701 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.