|
| WB19 - Variables browser and server |
| Iniciado por guest, 28,ene. 2015 10:17 - 5 respuestas |
| |
| | | |
|
| |
| Publicado el 28,enero 2015 - 10:17 |
Hi everybody,
I need to detect whether there have been changes in some field of the form so that when leaving the page I must give a warning and allow it to update the DB if the user wants. The actions that we perform are:
1. Define a boolean variable as global in the page. 2. I define a field on the form and leave it as hidden. 3. Sortie avec modification (onchange) (navigateur) a. I set the variable Boolean to TRUE b. I set the hidden field to 1 4. Click (onclick) Output Pin (navigateur) a. The boolean variable and kept hidden field value of 1 which I have put in point 3. 5. Click (serveur) AJAX not activated a. Neither fields (boolean and hidden) maintain the value 1, so I can not update the DB when any of these fields is set to 1 because I detect any change with an IF statement and the fields always have value zero.
The problem is that I can not share variables between the browser and server.
Does anyone know how to do a process like this?
Thanks in advance. Jordi
How I can do this ?. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 28,enero 2015 - 11:19 |
Hi Jordi,
You can communicate with the server with Ajax. So if you want to set a global variable from browser code you need to: - create an Ajax-enabled local procedure that sets the variable in server code - Do an AjaxExecute to this procedure in browser code
Local procedure: Procedure SetVar(bValue) //Ajax enabled bMyGlobal=bValue
In Browser code: Ajaxexecute(SetVar,True)
The use of hidden fields can also be a solution, but you need to keep in mind that they will only be updated on the server side if a submit action is executed.
Regards, Piet |
| |
| |
| | | |
|
| | |
| |
| Publicado el 28,enero 2015 - 11:37 |
Hi Piet, thanks for your answer. I am absolutely newbie in Ajax, so let me one more question, please. You say that set to TRUE my variable in the browser code. In the server code I can retrieve the value of the variable?
I gonna try your suggestions.
Ttanks again.
Salutacions / regards Jordi |
| |
| |
| | | |
|
| | |
| |
| Publicado el 28,enero 2015 - 11:56 |
Hi Jordi
there is a good chance that your problem is in point "5. Click (serveur) AJAX not activated"... The fact that the hidden field value is not sent to the server means that the settings on your button (where yo click in 5) are incorrect, and you need to set that button as SUBMIT type, so that it sends the value of the fields to the server...
This way, you'll get your hidden field AND the new values from the user input to the server side
Best regards |
| |
| |
| | | |
|
| | |
| |
| Publicado el 28,enero 2015 - 12:07 |
Hi Fabrice,
the question is that the exit button I set in my form, contains 2 blocks of code qhen the user clicks on :
1rs block : detect if a change has happen in this case, send a message to user and then he/she decide if wants to save changes before exit.
2nd block: weather the changes are saved or not, I must return to previous page. If AJAX option is activated (server), the sentence PageAffiche() is not allowed..
Probably I'm doing this in a bad way, isn't it?
Thanks. Jordi |
| |
| |
| | | |
|
| | |
| |
| Publicado el 28,enero 2015 - 12:55 |
Hi Jordi,
That's correct. You can enable AJAX in the top bar of the code window of the local (server) procedure.
To reply to your other question: Don't enable AJAX in your exit button. Then all is submitted to the server, so browser and server will be in sync.
Regards, Piet |
| |
| |
| | | |
|
| | | | |
| | |
|