how and where can i set a default value in a selcted box from a SESSION variable
how and where can i set a default value in a selcted box from a SESSION variable
Hello,
I have 2 selected boxes in the datatable. These are filled from the database of 3 tables. These are users, departments and message. Via a join (user ID in the table user = $ _SESSION ['USER_ID] -> department ID -> department ID of the table area -> department name) I let the message select the department name. How and where can I use the variable $ _SESSION ['AREA_ID'] to pass the corresponding value as default value, so when preselecting new data records or when editing the area of the user I preselected ?.
After a long search and trying different examples I have not yet found the right solution.
Since I have no public website attached the code message controller (Ajax query) and messages (output of the table).
Enclosed the code in the files and a screenshot. The user has the area ID 15 = EDV, which is why this is selected.
Thanks for any help. I hope my bad english and the problem is understandable.
Sorry for the bad english
Many Thanks
Dirk Zerenner
Answers
Hi Dirk,
There are two options:
1) Have the PHP generate the Javascript - that way you can do something like:
2) Ajax load the values you want for the defaults (using
$.ajax()
for example) and then use thefield().def()
method to set the default for the field.Allan