SteSpeak Posted February 25, 2007 Share Posted February 25, 2007 Hey, this is my first post at the community, I will be staying here longer =) I have a question. I am wondering if it's possible to have a variable which updates itself without actually having to refresh or go to a new page? It's for a order system, where users are customizing their order. I want the variable to be able to read the options from the form and display how much that specific selection will cost (by reading data from the database). Is this possible? If not, is there a next-best-thing to try to achieve similar results? Thank you - Stephen Link to comment https://forums.phpfreaks.com/topic/40068-real-time-dynamic-variable/ Share on other sites More sharing options...
papaface Posted February 25, 2007 Share Posted February 25, 2007 Javascript is what you need. It is very easy to remember that anything client-side (our side) is for something such as javascript. Anything server-side (server) is for a scripting language such as PHP. Link to comment https://forums.phpfreaks.com/topic/40068-real-time-dynamic-variable/#findComment-193790 Share on other sites More sharing options...
SteSpeak Posted February 25, 2007 Author Share Posted February 25, 2007 Thanks for the quick reply, I don't know much about javascript at the moment but I do intend to learn. Just a quick question? Can PHP and Javascript work togethor? Thanks Again Edit: I am going to try and use sessions to use PHP and Javascript together. Link to comment https://forums.phpfreaks.com/topic/40068-real-time-dynamic-variable/#findComment-193792 Share on other sites More sharing options...
fert Posted February 25, 2007 Share Posted February 25, 2007 PHP and javascript can work together using Ajax Link to comment https://forums.phpfreaks.com/topic/40068-real-time-dynamic-variable/#findComment-193794 Share on other sites More sharing options...
nloding Posted February 25, 2007 Share Posted February 25, 2007 PHP can write Javascript just as it writes HTML via echo, for instance. But PHP can't take a variable Javascript is using and use it as it's own. PHP and Javascript can share cookies, as I recently learned, so you can pass some information that way. The best way to avoid page refresh and use PHP or any other server side language is Ajax -- asynchronously updating part of page. Check out www.ajaxfreaks.com for more info, or google "ajax tutorials" ... there are a ton out there. A great book I just finished is "Beginning Ajax with PHP" from Apress. The general principle there is to call "yourscript.php" with Ajax, and have javascript input the $_GET elements ... if it's a form, for instance, Javascript parses the values in the form using the DOM and passes them as "yourscript.php?item=1342&sort=name&page=5" or whatever. Link to comment https://forums.phpfreaks.com/topic/40068-real-time-dynamic-variable/#findComment-193796 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.