I have a select object on my edit form with 3 items in the list:
["item 1","item 2", "Item 3"]
What I need is to make 'item 1' be the default value shown/selected on the edit form regardless of whether it is a new record or not.
How do I accomplish this?
Welcome to the nuBuilder Forums!
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.
How to always show a default value in a select field Topic is solved
-
- nuBuilder Team
- Posts: 4454
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 75 times
- Been thanked: 494 times
- Contact:
Re: How to always show a default value in a select field
One possibility is to add this JavaScript to the form's Custom Code:
nuSetValue('your_select_id_here','item 1');
Re: How to always show a default value in a select field
The javascript works, but I need to do it only if it is a new record being created, and I also want to set two other select fields in a similar fashion.
I tried this javascript to accomplish that, but it does nothing, and no errors. What am I doing wrong?
I tried this javascript to accomplish that, but it does nothing, and no errors. What am I doing wrong?
Code: Select all
function nuFormAfterDisplay() {
// Check if a new record is being created
if (nuIsNewRecord()) {
// Set the value of the select object
nuSetValue('pk_finalDoughIngred1','sourdough starter');
nuSetValue('pk_finalDoughIngred2','water');
nuSetValue('pk_finalDoughIngred3','salt');
}
}
-
- nuBuilder Team
- Posts: 4454
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 75 times
- Been thanked: 494 times
- Contact:
Re: How to always show a default value in a select field
There is no
Just place this in the form's Custom Code / Edit field:
nuFormAfterDisplay
function in nuBuilder. Did AI come up with that?Just place this in the form's Custom Code / Edit field:
Code: Select all
if (nuIsNewRecord()) {
// Set the value of the select object
nuSetValue('pk_finalDoughIngred1','sourdough starter');
nuSetValue('pk_finalDoughIngred2','water');
nuSetValue('pk_finalDoughIngred3','salt');
}
Re: How to always show a default value in a select field
Yes, Ai DID come up with that (grin). Thanks for the corrected code. Worked like a charm!