Im very new to java script, I have a couple of forms that need to have multiple java script actions applied.
Can I place them seperately?
below is an example.
THey don't seem to work unless I only have one item in the js console
fd.spRendered(function() {
function hideOrShowGrid() {
if (fd.field('New_x0020_ingredients').value == 1) {
// Show the grid field
$('.grid-to-hide').$parent.$el.show();
} else {
// Hide the grid field
$('.grid-to-hide').$parent.$el.hide();
}
}
// Calling hideOrShowDueDate when the user changes the Start Date
fd.field('New_x0020_ingredients').$on('change',hideOrShowGrid);
// Calling hideOrShowDueDate on form loading
hideOrShowGrid();
});
on edit form
//add submit button to the toolbar
fd.toolbar.buttons.unshift({
class: 'btn-outline-primary',
text: 'Submit',
click: function() {
fd.field('Status').value = 'Submitted for Approval';
fd.save();
}
});
And the Choice field store value as a string, so if the choice options are yes, no and blank, you need to use this code:
fd.field('New_x0020_ingredients').value == 'yes'
I've updated the code, please test it.
fd.spRendered(function() {
function hideOrShowGrid() {
if (fd.field('New_x0020_ingredients').value == 'yes') {
// Show the grid field
$('.grid-to-hide').show();
} else {
// Hide the grid field
$('.grid-to-hide').hide();
}
}
// Calling hideOrShowDueDate when the user changes the Start Date
fd.field('New_x0020_ingredients').$on('change',hideOrShowGrid);
// Calling hideOrShowDueDate on form loading
hideOrShowGrid();
});