I am very new to Java Script / JQuery and would like some help please.
- I have a form where the user clicks on a check box.
- Once clicked 2 fields (New Vehicle & New Company) displays with field rules.
- The use selects a vehicle registration number from the drop down field "New Vehicle"
- Forms lookup then populates the "New Company" field with a company name.
My JQuery script kicks off when the check box is clicked and populates another empty single line field based on certain conditions.
The issue I am having is that the JQuery code does not run when the lookup populates the "New Company" field with a value, but when I manually enter the value, the code executes as expected.
After Lookup
After Manual Entry
//User clicked on edit
$(".evehicle").click(function () {
var checkEdit = $(".evehicle :checked").val();
var nCompany = $(".ncompany input").val();
if ((checkEdit == "Yes") && (nCompany == "XXXX" || nCompany == "YYYYY")) {
$(".frule input").val("Show")
}
else if ((checkEdit !== "Yes") && (com == "XXXX" || com == "YYYYY")) {
console.log("Value of company edit uncheck: " + com);
$(".frule input").val("Show")
}
else if (checkEdit == "Yes") {
$(".ncompany").change(function () {
var newCompany = $(".ncompany input").val();
if ((newCompany == "XXXX" || newCompany == "YYYYY") && (checkEdit == "Yes")) {
$(".frule input").val("Show");
}
else {
$(".frule input").val("Not Show");
}
});
}
else {
$(".frule input").val("Not Show");
}
});