Hi,
Can someone here tell me how to select specific option from dropdown list using PHP?
Regards.
Select specific option from dropdown list using PHP
Select specific option from dropdown list using PHP
AppGini 5.92 - Upgraded to 5.94
Re: Select specific option from dropdown list using PHP
Hi,
PHP is used on the server side. The dropdown is used on the client side. So what are you trying to do?
PHP is used on the server side. The dropdown is used on the client side. So what are you trying to do?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Select specific option from dropdown list using PHP
Actually, I've heard from someone that javascript is not secure enough...
By the way... how about using jquery to do so?
By the way... how about using jquery to do so?
AppGini 5.92 - Upgraded to 5.94
Re: Select specific option from dropdown list using PHP
Hi ayussuf,
if you want to make a pre-selection for the user JS is fine.
If you want to force the user to choose option X, you will need to add an additional check for example in the hooks/tablename -> before_update function. There you can change the dropdown using PHP to the value you want, ignoring any user's choice.
With JS probably pbötcher can help you when you post a list of item and tell us, which one should be selected.
Olaf
if you want to make a pre-selection for the user JS is fine.
If you want to force the user to choose option X, you will need to add an additional check for example in the hooks/tablename -> before_update function. There you can change the dropdown using PHP to the value you want, ignoring any user's choice.
With JS probably pbötcher can help you when you post a list of item and tell us, which one should be selected.
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
Re: Select specific option from dropdown list using PHP
Thank you Olaf,
Is it possible using PHP in the hooks/tablename -> before_update function to pre select the specific option in dropdown list and user can change if he want to change? or at least can be displayed before the record being saved.
What I've done now was setting the $data[field] to specific record. But the problem is this selection was not displayed in the detail view before I save the record. It will only being displayed after the record have been saved first.
Actually I've tried doing this using jquery. But it just changing the value and text of the field. But the autofill field related to it didn't changed.
Is it possible using PHP in the hooks/tablename -> before_update function to pre select the specific option in dropdown list and user can change if he want to change? or at least can be displayed before the record being saved.
What I've done now was setting the $data[field] to specific record. But the problem is this selection was not displayed in the detail view before I save the record. It will only being displayed after the record have been saved first.
Actually I've tried doing this using jquery. But it just changing the value and text of the field. But the autofill field related to it didn't changed.
AppGini 5.92 - Upgraded to 5.94
Re: Select specific option from dropdown list using PHP
Hi,
the before_update is only run after the user clicks the save button. So this is the wrong place for something like this.
It's probably much easier to use jquery to select an option.
The other possibility (which I suppose is way more complicated) would be to manipulate the dropdown list before it is rendered in the browser. Probably in the _init function.
But well, you have the jquery to change the value, so why not use a different jquery to set the autofill to the value you want? Doesn't this work?
Olaf
the before_update is only run after the user clicks the save button. So this is the wrong place for something like this.
It's probably much easier to use jquery to select an option.
The other possibility (which I suppose is way more complicated) would be to manipulate the dropdown list before it is rendered in the browser. Probably in the _init function.
But well, you have the jquery to change the value, so why not use a different jquery to set the autofill to the value you want? Doesn't this work?
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view