You are viewing limited content. For full access, please sign in.

Discussion

Discussion

Form default value in look-up

posted on August 29, 2018

Hi,

Does anyone know how to default a value to a text and drop-down fields linked to a DB table or a Stored Proc with a look-up rule?

I have requirements where a default value is selected but the same field allows selecting/entering a different value.

Thanks in advance,

Adarsh

0 0
replied on August 29, 2018

Depending on whether the lookup is carried out when the page loads, or whether it's caused by a user action, you'll want to use one of the following events: 'onloadlookupfinished' or 'lookupcomplete'.

In the following sample, I'm setting the default value of a drop-down field that looks up all 50 US states to 'Arkansas'. The drop-down field has ID Field63. This particular lookup occurs when the page loads, so I use 'onloadlookupfinished'. The script waits for the lookup to complete before setting the default value.

$(document).ready(function () {
  $(document).on('onloadlookupfinished', function(event) {
    $('#Field63').val('Arkansas');
  })
})

This sample assumes that there's only one lookup on the page. If you have multiple lookups on a page, you'll want to check the triggerId of the event before setting a default value. The link above explains how to use triggerIds.

0 0
replied on August 30, 2018 Show version history

Hi Leif,

Thanks for the answer. When I am submitting a new form, I click a radio button option called New and get an empty state field with a choice of 50 states. When the form is submitted with Arkansas as the state, the data is stored in a purpose built DB table.

Since my form is quite long, users can select a previously submitted form by clicking the radio option called existing and then they are presented with a dropdown field to select previously selected forms. Selecting one of these fills out the entire form. This is where I want Arkansas to be selected by default but with an option to select another state if required.

Regards,

Adarsh

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.