Menu
Welcome, Guest
Username: Password: Remember me

TOPIC: Hide fields conditionally

Hide fields conditionally 3 months 1 week ago #87029

  • presleytarian
  • presleytarian's Avatar
  • Offline
  • New Member
  • Posts: 4
  • Thank you received: 1
  • Karma: 0
Hi,
SuiteCRM 7.11.4
I'm trying to hide fields conditionally. I am, however, a kludge artist and ineffectual code monkey, so have likely got something terribly wrong.

I'm attempting to follow the instructions HERE with a side-order of THIS TUTORIAL, please laugh at me all you want.
So, in /custom/modules/Contacts/metadata/detailviewdefs.php It has
array (
          'file' => 'modules/Contacts/Contact.js',
          'file' => 'custom/modules/Contacts/hideminister.js',

The file /custom/modules/Contacts/hideminister.js reads as follows
(function(){
  if ($("#roll_c").val() = "0") {
    $("#LBL_MIN_NOTES").hide();
    $("#min_notes_c").closest("td").hide();
	$("#LBL_MINSTREAM").hide();
    $("#minstream_c").closest("td").hide();
	$("#LBL_ORDINATION").hide();
    $("#ordination_c").closest("td").hide();
	$("#LBL_ROLL").hide();
    $("#roll_c").closest("td").hide();
	$("#LBL_CERTOFGS").hide();
    $("#certofgs_c").closest("td").hide();
	$("#LBL_STUDYLEAVEACCRUED").hide();
    $("#studyleaveaccrued_c").closest("td").hide();
	$("#LBL_STUDYLEAVEUSED").hide();
    $("#studyleaveused_c").closest("td").hide();
	$("#LBL_EMERITUS").hide();
    $("#emeritus_c").closest("td").hide();
	$("#LBL_ORM").hide();
    $("#orm_c").closest("td").hide();
   }else{
    $("#LBL_MIN_NOTES").show();
    $("#min_notes_c").closest("td").show();
	$("#LBL_MINSTREAM").show();
    $("#minstream_c").closest("td").show();
	$("#LBL_ORDINATION").show();
    $("#ordination_c").closest("td").show();
	$("#LBL_ROLL").show();
    $("#roll_c").closest("td").show();
	$("#LBL_CERTOFGS").show();
    $("#certofgs_c").closest("td").show();
	$("#LBL_STUDYLEAVEACCRUED").show();
    $("#studyleaveaccrued_c").closest("td").show();
	$("#LBL_STUDYLEAVEUSED").show();
    $("#studyleaveused_c").closest("td").show();
	$("#LBL_EMERITUS").show();
    $("#emeritus_c").closest("td").show();
	$("#LBL_ORM").show();
    $("#orm_c").closest("td").show();
   })();

Any advice on what I have seriously screwed up (or how I can figure out why it isn't doing anything) would be much appreciated.
The administrator has disabled public write access.

Hide fields conditionally 3 months 1 week ago #87046

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 11152
  • Thank you received: 1670
  • Karma: 380
Start with a simple js function, with only an alert. Check if it is getting loaded into your page (you should see it in the page source).

You might need some Javascript rebuild from Admin / Repairs

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.
The following user(s) said Thank You: presleytarian
Time to create page: 0.054 seconds
Powered by Kunena Forum