This topic is locked

Automatically select first item in dropdown during Add page

3/1/2021 12:11:19 AM
PHPRunner General questions
need2sleep authorDevClub member

In PHPR we have the option to set 'Default Value' inside the properties page of a given field.
What do you do in a situation when the default value can not be determined? For example, if you are using a Lookup wizard and the user sets all the values. Unfortunately, the default value cannot always be hard-coded.
Since you want to speed up the data entry process and want to automatically have PHPR select the first available item on the Lookup Wizard's drop down, what would be the best way to execute this?

need2sleep authorDevClub member 3/4/2021

Thank you Sergey for the direction. I was able to figure it out with your help and understanding how Jquery works.
For anyone coming by this post in the future, here is what I did:
In the 'Events' section, on the 'Add page', under 'JavaScript OnLoad event', I added the following line:

$("#target")[0].selectedIndex = 1;


Target being the object you want to modify and the number '1' the index number of the item. In my case it was a Lookup wizard for setting a client's lead type. To find the name of the object, simply use Inspect Element in your web browser by right clicking the drop down element.

$("#value_LeadType_1")[0].selectedIndex = 1;


Also there is a great video by Corrie de Wet on his YouTube channel going over the introduction to JQuery: https://www.youtube.com/watch?v=oJq8akQyzuo