Announcements
Hello,
i have a dropdown column with few values and there is "Other" one of the value. So as soon as user select "Other" value from the drop-down another text box will pop-up on the form. it was working before on the form but all of a sudden not displaying the text box. is there any idea what could be the issue?
$(document).ready(function () { MyFieldChanged(); $('#custom_preference').on("change", MyFieldChanged); }); function MyFieldChanged() { $("#custom_text").closest("tr").hide(); var selectedValue = $('#custom_preference').val(); if (!!selectedValue && selectedValue == 881990007) { $("#custom_text").closest("tr").show(); } else { $("#custom_text").closest("tr").hide(); } }
Thanks Steve for your answer.
Hi Rakki,
Based on your code, it should work if your logical name "#les_others" is correct. You could press f12 to check it.
And I noticed that the other would show whatever your if condition is true or false.
Please change to code like this:
if(selectedValue && selectedValue == 100000007){
console.log(true);
$("#les_others").closest("tr").show();
}
else{
console.log(false);
$("#les_others").closest("tr").hide();
}
And you could know which branch is executed by the output in console. Please clear your cache to have a try.
Hello Steve,
Still "Others" text box not showing up on the form even though Other option value is getting "100000007" when selected from the drop-down as you can see in the below picture. what else causing the issue you think?
Appreciated for your help.
Hi Rakki,
Based on the screenshot you provide, the issue should cause by your filed name is wrong. Please change $('#les_Perference').val() to $('#les_perference').val() at line426 in your screenshot.(The P should be lower case as the same as it at the line419)
Steve,
appreciated for your reply. i was able to debug and noticed when i am selecting "Other" from drop-down is getting "undefined" value and getting into else condition to hide the text box. what could be the reason to get "undefined" value and how to resolve it?
Thanks in advanced.
Hi Rakki,
You could add debugger; or console.log(object) in you code. Something like this:
$(document).ready(function () {
MyFieldChanged();
$('#custom_preference').on("change", MyFieldChanged);
});
function MyFieldChanged() {
debugger;
$("#custom_text").closest("tr").hide();
console.log($("#custom_text").closest("tr"));
var selectedValue = $('#custom_preference').val();
if (!!selectedValue && selectedValue == 881990007) {
$("#custom_text").closest("tr").show();
}
else {
$("#custom_text").closest("tr").hide();
}
}
Then press F12 to debug or view the console.
Hello Steve,
Thanks for your reply. alert function is working within JavaScript but text field not displaying. i am using advanced form within the wizard and entering the JS into form options.
so how can i debug the JavaScript which residing into CRM Backend?
Hi Rakki,
I tested your code on my side and it could work fine.
Below is my test:
1. Add JS code to my basic form.
Result:
You can try the following points:
1. Clear the cache of your browser and reopen your portal.
2. Press F12 to see there is any error.
3. Debugger your code to see that does it run well.
André Arnaud de Cal...
294,206
Super User 2025 Season 1
Martin Dráb
232,968
Most Valuable Professional
nmaenpaa
101,158
Moderator