[SOLVED] Default DropDown value on add page |
5/22/2025 18:46:03 | |
| PHPRunner General questions | ||
|
A
asawyer13 authorDevClub member
I want to set a default dropdown id on an add page. Can't seem to make it happen. I'm actually grabbing the id from the url but I know it's getting the proper value I am trying this: if (isset($_GET['q']) && $_GET['q'] !== '') {Alan |
||
|
|
ChatGPT 5/22/2025 |
|
Certainly! In PHPRunner, if you want to set a default value for a dropdown field on the add page based on a value you are retrieving from the URL, you can do it using the
Here’s an updated example:
|
|
|
A
|
asawyer13 authorDevClub member 5/22/2025 |
|
Yes, chatgpt told me the same thing, but it doesn't work. Alan |
|
|
|
lefty 5/22/2025 |
|
I think PHPrunner requires defaultValue if (isset($_GET['q']) && trim($_GET['q']) !== '') { |
|
|
A
|
asawyer13 authorDevClub member 5/22/2025 |
|
I'm putting the code in the BeforeProcessAdd event. I get a syntax error with my code and lefty's so I wanted to make sure I was putting it in the right event. Alan |
|
|
A
|
asawyer13 authorDevClub member 5/22/2025 |
|
A
|
asawyer13 authorDevClub member 5/22/2025 |
|
If I put the code in the BeforeShowAll event, I don't get an error, but it doesn't do anything. |
|
|
|
Sergey Kornilov admin 5/22/2025 |
|
What is "default dropdown id"? |
|
|
A
|
asawyer13 authorDevClub member 5/22/2025 |
|
My table is in my add page I have a lookup So in this case Seq = 7 has a name of "Vendor Report" so I would like Vendor Report to be selected when the add page is opened. |
|
|
|
Sergey Kornilov admin 5/23/2025 |
|
So, you are talking about a "default value" of a field. The best option to set default value is to use ProcessRecordValues event of the Add page: Simplified code: |
|
|
A
|
asawyer13 authorDevClub member 5/23/2025 |
|
Thanks, I thought I had tried that at one point, but I suspect I put it in the wrong event. |
|