Nintex for SharePoint Forum
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
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.
Solved! Go to Solution.
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.
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.
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:
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.
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]
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)
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*'); } }); });
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.
@emha Thanks for the solution. On a simple form I have two fields Type and Title. I want to update Title based on the options I select in the Type.
Type (One, two, three). I want title to show - " selectedType: + Date". When user changes the type then title should change. Following modified script isn't working
WF.FormFiller.Events.RegisterAfterReady(function () {
NWF$(".Type").change(function(evt){
var MyTitleValue = NWF$('.' + Type).val();
NWF$(".Title").val(MyTitleValue);
});
});