Jump to content

Real Time Dynamic Variable


SteSpeak

Recommended Posts

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

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.