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

JavaScript Auto Select

Jump to solution

This is maybe a simple thing to fix but I'm a little up against time.

I have two 'Choice Controls' which are being used as 'Tabs'. These choice controls are the same other than one additional option to the second choice control. Only one choice control is visible at any time (created rules on the choice controls).

When opening the form for a 'new item' the 'maintab' is by default on 'Job Details' and so is the hidden 'AuthorisationTab'. As such, I have placed a rule on the Job Details panel to only show when both tabs have 'Job Details' selected. This works.

The problem occurs when I have used a workflow to import jobs from an 'Import' list. All of the information is entered where it should be but when I open the form the tabs, the panels, everything is all haywire.

What I thought would fix the problem is for JavaScript to automatically select 'Job Details' on both 'maintab' and 'authtab' every time the form is opened. These controls already have their default values as 'job details' but after workflowing information into the list it seems to ignore this.

These choice controls are not connected to a field in the list, they are for tab purposes only. They do have client IDs though to use for JavaScript.

I may figure it out in the next few attempts, but if not hopefully someone can provide some example code to help me fix this silly problem.

Thank you,

Andrew

Tags (3)
0 Kudos
Reply
1 Reply
andrew_valentin
Nintex Newbie

Re: JavaScript Auto Select

Jump to solution

UPDATE:

Solution:

function ResetTabs(){

var rad = NWF$('#' + mainTabButton);

var authrad = NWF$('#' + Authorisationtab);

var hazard = NWF$('#' + hazardtab); 

//above are my 3 fields I want to change when this code runs//

rad.prop('checked',false);

authrad.prop('checked',false);

hazard.prop('checked',false);

//above is the code that 'unchecks' any current selections on these choice fields//

rad.find('input').each(function(){

if(this.value == "Job Details"){

this.checked = true;

} });

authrad.find('input').each(function(){

if(this.value == "Job Details"){

this.checked = true;

} });

hazard.find('input').each(function(){

if(this.value == "Working Environment"){

this.checked = true;

//above we define what specific value we want to set these fields to//

} })};

This unchecks the values of certain fields and then re-assigns a specified value to them. I have written this as a function 'ResetTabs()' which allows me to attach it to the save button or any other buttons on the form via the 'client click' function.

I can also have some code to run when the form opens rather than only when it saves:

NWF$(document).ready(function(){

NWF$(':radio[value="Job Details"]').attr('checked',true);});

Andrew

Support obtained via another post that can be found here "Default Values Using Javascript "

0 Kudos
Reply