Hi!
I am trying to call a javascript method by using sc_ajax_javascript,
but is there anyway to retrieve the return value from the javascript method?
I donât believe so as JS runs on client side and PHP runs on server side.
One way around it is to get the JS to create a small text file with a status / return value in it, and then get your PHP to check / read that file. Make sure you clean up before / afterwardsâŚ
javascript return method by using sc_ajax_javascript
[QUOTE=Brian;29641]Hi!
I am trying to call a javascript method by using sc_ajax_javascript,
but is there anyway to retrieve the return value from the javascript method?[/QUOTE]
Would need to know the method to pass a variable / result from javascript to php.
I have a form, and the âOnValidateâ event
I need to grab the return value of a function in javascript.
The function of javascript, would have to modify the field_Result {} field and return a result to php.
Iâve tried using the macro sc_ajax_javascript (), but it has not worked for me. But if I could pass a variable from php to javascript with the macro
sc_ajax_javascript (âParam1â, âParam2â);
The code I use is as follows:
php (OnValidate) -----
sc_ajax_javascript (âValidarOpcionâ);
if ({field_Result == âyesâ) {OpenForm}
âŚ
javascript ------
ValidarOpcion () {
if (confirm (âWould you like continue?â)) {
Field_Result {} = 'True';
} Else {
Field_Result {} = 'False';
}
}
I have also tried to use the javascript function within the php code with:
echo â<script> confirm (âTesting Javascript in PHP eventsâ); </ script>â;
but I could not capture the results confirm ()
$ Var = echo â<script> confirm (âTesting Javascript in PHP eventsâ); </ script>â;
Thanks in advance
see post above yours.
The answer is not âeasilyâ because the JS and PHP bits run at different times (one on server and one on client)
[QUOTE=adz1111;33685]see post above yours.
The answer is not âeasilyâ because the JS and PHP bits run at different times (one on server and one on client)[/QUOTE]
Alternative ???
I use php to javascript option because not know another way to do it. The point is I want to run the php code, send a message to the user to
âAcceptâ or âcancelâ and function of the option selection, php execute one form or another grid.
Alternative option:
javascript saved text file with variables and values. Since php read the file generated in javascript and parseamos to recover the variable and its values.
Create a javascript function thath calls a php file, using POST GET to pass variables, control from JS returning values and confirmation dialogs. âEasyâ