Display Form does not display comments
Hi,
I have the following script on my display form but it is not displaying the comments as per the choices selected:
Shorter version of the query:
// Enable or disable 'Comment Fields'
function setComment() {
var a = fd.field('Engine_x0020_Oil_x0020_Level').control()._el().text();
var b = fd.field('Fluid_x0020_Leaks').control()._el().text();
// set the priority index for 'a'
if (a == '0') {
$('.C1').show(); // Enable
}
else {
$('.C1').hide(); // Disable
}
// Priority index for b
if (b == '0') {
$('.C2').show(); // Enable
}
else {
$('.C2').hide(); // Disable
}
}
// Subscribe on status change
fd.field('Engine_x0020_Oil_x0020_Level').control().change(function () {
setComment();
});
fd.field('Fluid_x0020_Leaks').control().change(function () {
setComment();
});
// Initialize
setComment();
On new and edit forms i am using these fields and they work fine:
fd.field('Engine_x0020_Oil_x0020_Level').control().value();
I want to display the comments where the action required (0) is selected and a comment is left.
Can you please tell me why am I not seeing the comments on the display side.
Thanks,
Mariam
I have the following script on my display form but it is not displaying the comments as per the choices selected:
Shorter version of the query:
// Enable or disable 'Comment Fields'
function setComment() {
var a = fd.field('Engine_x0020_Oil_x0020_Level').control()._el().text();
var b = fd.field('Fluid_x0020_Leaks').control()._el().text();
// set the priority index for 'a'
if (a == '0') {
$('.C1').show(); // Enable
}
else {
$('.C1').hide(); // Disable
}
// Priority index for b
if (b == '0') {
$('.C2').show(); // Enable
}
else {
$('.C2').hide(); // Disable
}
}
// Subscribe on status change
fd.field('Engine_x0020_Oil_x0020_Level').control().change(function () {
setComment();
});
fd.field('Fluid_x0020_Leaks').control().change(function () {
setComment();
});
// Initialize
setComment();
On new and edit forms i am using these fields and they work fine:
fd.field('Engine_x0020_Oil_x0020_Level').control().value();
I want to display the comments where the action required (0) is selected and a comment is left.
Can you please tell me why am I not seeing the comments on the display side.
Thanks,
Mariam
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi Mariam,
You do not need to use change handler in a display form, it will never be triggered. Just call setComment on form loading.
Output a and b variables to find text representation of field values:
Then use those values in your conditions.
You do not need to use change handler in a display form, it will never be triggered. Just call setComment on form loading.
Output a and b variables to find text representation of field values:
Code: Select all
var a = fd.field('Engine_x0020_Oil_x0020_Level').control()._el().text();
alert(a);
var b = fd.field('Fluid_x0020_Leaks').control()._el().text();
alert(b);
Hi Dmitry,
Thanks for the reply!
Adding the alert(a); has caused the form to prompt for a message for all the fields I have in the script before it even loads the page but it is still now showing the comment when the condition is true on the display form.
Script:
// Enable or disable 'Comment Fields'
function setComment() {
var a = fd.field('Engine_x0020_Oil_x0020_Level').control()._el().text();
alert(a);
var b = fd.field('Fluid_x0020_Leaks').control()._el().text();
alert(b);
// set the priority index for 'a'
if (a == '0') {
$('.C1').show(); // Enable
}
else {
$('.C1').hide(); // Disable
}
// Priority index for b
if (b == '0') {
$('.C2').show(); // Enable
}
else {
$('.C2').hide(); // Disable
}
}
//Initialize
setComment()
I have attached a JPEG to explain my issue.
Thanks, Mariam
Thanks for the reply!
Adding the alert(a); has caused the form to prompt for a message for all the fields I have in the script before it even loads the page but it is still now showing the comment when the condition is true on the display form.
Script:
// Enable or disable 'Comment Fields'
function setComment() {
var a = fd.field('Engine_x0020_Oil_x0020_Level').control()._el().text();
alert(a);
var b = fd.field('Fluid_x0020_Leaks').control()._el().text();
alert(b);
// set the priority index for 'a'
if (a == '0') {
$('.C1').show(); // Enable
}
else {
$('.C1').hide(); // Disable
}
// Priority index for b
if (b == '0') {
$('.C2').show(); // Enable
}
else {
$('.C2').hide(); // Disable
}
}
//Initialize
setComment()
I have attached a JPEG to explain my issue.
Thanks, Mariam
- Attachments
-
- Display Form Issue.jpg (91.85 KiB) Viewed 4040 times
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
What values it shows during loading the form (values of a and b)?
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
OK. You should use those values in the conditions from your code, ex.:
if (a == 'Okay') {...
if (a == 'Okay') {...
-
- Information
-
Who is online
Users browsing this forum: No registered users and 5 guests