Member_2_908359
asked on
call a php function from a button
how can I call a php function from a button (onClick=....)?
it works if I call an external php script, using javascript:location.href=. .. but not when calling a function declared in the same file.
php function is ok and works if called within the php code.
the only thing I could do was to trigger a javascript function which does an echo of all php lines. pretty heavy...
does anyone has a smarter way?
it works if I call an external php script, using javascript:location.href=.
php function is ok and works if called within the php code.
the only thing I could do was to trigger a javascript function which does an echo of all php lines. pretty heavy...
does anyone has a smarter way?
ASKER
do you mean I should use Ajax or this is the principle of ajax where the server uses javascript to update the client screen? I am not (as you probaly realized) a web man, I only know databses but I do occasional things on the web (difficult to bypass nowadays) mainyly php.
the return I expect from php is only true or false, I could even forget about it, it always works, and the app is not using important data. so how do I call a php function from a javascript then? (if I know php a bit, I almost ignore javascript, I use it with the book on my knees (not true, the js doc on my left screen).
is there a call/exec command? how to distinguish external php scripts from internal php functions? and is thre a way to stay in the same web page during execution to minimize blank screens?
the return I expect from php is only true or false, I could even forget about it, it always works, and the app is not using important data. so how do I call a php function from a javascript then? (if I know php a bit, I almost ignore javascript, I use it with the book on my knees (not true, the js doc on my left screen).
is there a call/exec command? how to distinguish external php scripts from internal php functions? and is thre a way to stay in the same web page during execution to minimize blank screens?
ASKER
forget to mention that I use php to write to mysql mainly, can js talk to mysql directly if the mysql port (def: 3306) is open to public?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
this is it, provided I can understand what this XMLHttpRequest does... do I need something special on my server to respond to this?
I'll copy the code locally to re-read it (such awful colors! maybe I should give this guy a few readability courses!).
and a philosophic remark, it is really too much energy to spend to get a name displayed, someting which is done with 2 lines of sql, 2 lines of servoy, 2 lines of filemaker.
The web definitly needs a query language which is something else than a bunch of tricks and workaround, no serious or complex app can be done this way unless you spend 2 years on it, and then come up with a huge price nobody would buy.
anyway, thanks for confirming there is no easy way to do this, I'll use yr example for my own understanding, but no way I do apps using this. the web world is rather weird, wants to be transparent and user friendly like classic apps, but has no language adapted for this.
I'll copy the code locally to re-read it (such awful colors! maybe I should give this guy a few readability courses!).
and a philosophic remark, it is really too much energy to spend to get a name displayed, someting which is done with 2 lines of sql, 2 lines of servoy, 2 lines of filemaker.
The web definitly needs a query language which is something else than a bunch of tricks and workaround, no serious or complex app can be done this way unless you spend 2 years on it, and then come up with a huge price nobody would buy.
anyway, thanks for confirming there is no easy way to do this, I'll use yr example for my own understanding, but no way I do apps using this. the web world is rather weird, wants to be transparent and user friendly like classic apps, but has no language adapted for this.
Personally I think PHP is rather neat :-) And Ajax after you get used to it is not awefully complicated, especially if you have readymade code to modify.
All in all, good luck! :)
All in all, good luck! :)
ASKER
I agree, php on its own is clean, but does not control anything on the UI unless you re-display the whole page at every query. still a bit old fashioned to do an application in 5 days...
None of these things are complex on their own, it's just that it makes dev very lengthy.
and thanks for the luck, I may need it!
None of these things are complex on their own, it's just that it makes dev very lengthy.
and thanks for the luck, I may need it!
Let me know if you need to know any more.