cancel
Showing results for 
Search instead for 
Did you mean: 
bimi82
Nintex Newbie

Update a field based on the selected value in a dropbox

Jump to solution

Right,

 

I have the following code, which I like to .change when the dropdown is == Recipient

How do I filter the var CollectedBy based on the selection?

NWF$(document).ready(function(){  
 var CollectedBy = NWF$(".CollectedByClass");  
 CollectedBy.change(function(){ 
  NWF$(".CollectedByUserClass").val('Testing'); 
  });
 });

Scenario:

If dropdown == Recipient then update .CollectedByUserClass to "Test1"

If dropdown == Somebody else then update to "Test2"

If nothing is selected then leave the field "blank".

 

I am getting frustrated over this ... can't find a reliable page on here which helps me in establishing it.

Labels: (1)
Tags (1)
0 Kudos
Reply
7 Replies
Highlighted
Community Manager Community Manager
Community Manager

Re: Update a field based on the selected value in a dropbox

Jump to solution

@bimi82 

 

For this, I think you can achieve what you are looking for without using javascript. You can use a form rule to set the value of another field based on the value from the dropdown.

dropdownupdate.JPG

For this form, I have set the title field to Choice 2 when the dropdown is equal to Choice 2. Otherwise set the title field to blank. Here is what the rule looks like and you can import the form into your list and see how it works.

 

dropdownupdate2.JPG

 

0 Kudos
Reply
bimi82
Nintex Newbie

Re: Update a field based on the selected value in a dropbox

Jump to solution

Hi @eharris04 

 

I am using the classic view also NOT the online version.
Besides, I do only have Formating | Validating as an option for the rule.

 

Also, see my other topic where I do not seem to get much support:

https://community.nintex.com/t5/Nintex-for-SharePoint/Append-value-from-dropdown-or-calculated-value...

 

 

0 Kudos
Reply
emha
Nintex Newbie

Re: Update a field based on the selected value in a dropbox

Jump to solution

 

assuming the dropdown is a choice control, the check might look like

 

...
CollectedBy.change(function(evt){
    if (evt.target.value == "Recepient" ){
        NWF$(".CollectedByUserClass").val('Test1'); 
    } else if (evt.target.value == "Somebody else" ){ 
        NWF$(".CollectedByUserClass").val('Test2'); 
    } else{
        NWF$(".CollectedByUserClass").val(''); 
    }
  });
...

EDIT: with the context of your other thread, make sure '.CollectedByUserClass' has to address single textbox control!

 

 

 

Also, see my other topic where I do not seem to get much support:

please be little patient, we can only react in our free time ...

it's already responded.

0 Kudos
Reply
bimi82
Nintex Newbie

Re: Update a field based on the selected value in a dropbox

Jump to solution

Hi @emha 

 

I now updated the code with your suggested one and it does this:

 

- when dropdown field (selection based) is set to Recipient then the single text field is blank

- when dropdown is set to Somebody else then it changes to Test2

- however, all rows do change as soon as you update the dropdown on any of the rows

 

Yes, the Single Text Field is [.CollectedByUserClass]

SingleLineTextbox.JPG

On otherside:

 

when I use the following, then it works perfectly on any row BUT of course the value 'Test' will be updated in the single text field as soon as the dropdown changes, no matter which selection is made.

 

 NWF$(document).ready(function(){  
 var setRecipient = NWF$(".CollectedByClass"); 
 setRecipient.change(function(){
  NWF$(".CollectedByUserClass").val('Test');
  });
 });

So, my idea was:

 

1) update the SingleLine Textbox for each row indepentadly depending on the dropdown == Recipient

2) update the SingleLine Textbox with a value from a PoG field (see below)

 

CollectedBy.jpg

0 Kudos
Reply
emha
Nintex Newbie

Re: Update a field based on the selected value in a dropbox

Jump to solution

taking into account explanation/details you provided in the other thred, I believe following code should be what you need

 

NWF.FormFiller.Events.RegisterAfterReady(function () {
    NWF$(".CollectedByClass").change(function(evt){
        var currRow = NWF$(evt.target).closest('.nf-repeater-row');
        var txtboxOnCurrRow = currRow.find(".CollectedByUserClass input.nf-associated-control");
        var PPFieldValue =  NWF$('#' + jsvarRecipientName).val();   // replace jsvarRecipientName (PoG control) with jsvarShowRecpientName if you want calc. val. control gets copied
        var currDDValue = evt.target.value;
        
        if (currDDValue == "Recepient" ){
            txtboxOnCurrRow.val(PPFieldValue); 
        } else if (currDDValue == "Somebody else" ){ 
            txtboxOnCurrRow.val('*change acc. needs*');
        } else{
            txtboxOnCurrRow.val('*empty value*'); 
        }
    });
});

 

0 Kudos
Reply
Community Manager Community Manager
Community Manager

Re: Update a field based on the selected value in a dropbox

Jump to solution

If possible,  check to see that you're running the latest version of Nintex forms. I built this using Nintex for SharePoint Server, and while I chose the responsive form designer, the rules allowed are the same. 

0 Kudos
Reply
bimi82
Nintex Newbie

Re: Update a field based on the selected value in a dropbox

Jump to solution
We use Nintex Forms Version: 4.3.3.0
Unfortunately, I do not see the option as you have demonstrated.
0 Kudos
Reply