How to complete one field based on entry in another?

  • 7 September 2017
  • 4 replies
  • 1 view

I currently have a form where users must enter a disk id number. The next field is a drop down with a list of server names. The disk numbers start with 1-7. If the disk starts with a 1, it came from server 1, if a 2, it came from server 2 and so on. How do I make the disk id automatically trigger the correct server name in the drop down list? Thanks in advance!


4 replies

Badge +9

If 'Disk id Number' is a 'Single line of Text' then try this JavaScript code.

NWF$(document).ready(function()
{  
NWF$('#'+ txtDiskNo).bind('input',function(){ 
               fnSetServerName();
    });
});
function fnSetServerName()
{
 var disk = NWF$('#'+ txtDiskNo).val();
 
 if(disk == 1)
 {
  NWF$('#'+ddlServer).val('Server1');
 }
 else if(disk == 2)
 {
  NWF$('#'+ddlServer).val('Server2');
 }
 else
 {
  NWF$('#'+ddlServer).val(' ');
 }
}

  

Thank you Lakshmi. I'm guessing I insert the code in Form Settings under Custom JavaScript

Badge +7

Not sure if this a prodction form yet or not, but one thing you could do if you didn't want to have JS in your form, is look at the new responsive forms. You can now set a rule for example:

Rule Name: Set Server to 1

When: startsWith("NamedControl Name", "1") == true

Then: Set Value

Named Control  = value you want to set

Only thing you would have to redo your form because you have to choose pixel perfect vs responsive. Good news is it takes 1/4 the time to create the responsive forms than the pixel perfect forms.

Userlevel 7
Badge +17

matt bonner‌ have you resolved your issue? Is any from the above answers helpful thus you could mark it as "correct"?

Regards,

Tomasz

Reply