/    Sign up×
Community /Pin to ProfileBookmark

Mixing PHP and Javascript

Ok guys, I am definately a newbie…

Been looking around for quite some time, but can’t find a clue how to accomplish a certain task. Some concept help would be a great.

I am laying out some pages that will eventually turn a users selections into an online order..The users selects choices from drop down boxes and live without refreshing the page(not submitting), with javascript (getelementbyid), I can read the boxes and start some calculations for the total cost. Problem I am having is…

After I read the boxes I need to to retrieve some calculation data from a database (mysql). Is it possible in javascript to insert an sql in PHP to retrieve calculation data? Or jump to a PHP routine from javascript and return with data? I’ve kinda got a working model by preloading the database to the html page before starting the javascript calculations and using a hidden input to pass data. I’ve done C++, Delphi(pascal), basic, asm…etc.
This preloading and passing in hidden seems really stupid. Peloading an entire database would have to slow down my pages considerable I think.

Anyway after the price is calculated the intention of course is to submit the page and all gets pretty smooth from there forward.

Actually I’ve seen this on someone else’s website and I think it’s sweet..The sight is [url]www.psprint.com[/url]

So in short, is there a better way?

Thanks ahead time for anyone’s thoughts or help on this..

Dabrag

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@aj_nscMay 16.2007 — 
...Or jump to a PHP routine from javascript and return with data?
[/quote]


AJAX....google it.
Copy linkTweet thisAlerts:
@DabragauthorMay 18.2007 — Thanks, I''l give it a try
Copy linkTweet thisAlerts:
@DabragauthorMay 18.2007 — Not trying to be a pain to anyone, but I did a bunch of reading and I think the short version of what I'm trying to is this

//all setup stuff..then

httpRequest.onreadystatechange = <?php Function() ?>;

httpRequest.open('GET', url, true);

httpRequest.send(null);

//then result is available in httpRequest?

I'm having comp trouble so I can't try this right now..But am I close?
×

Success!

Help @Dabrag spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...