Some JS code for item/record page

Share your custom code, plugins and themes.
Post Reply
Didou12
Posts: 487
Joined: 14 Jan 2023, 14:53
Name: Louis
Location: Montreal, Canada

Some JS code for item/record page

Post by Didou12 »

Hi everyone,

Here is some JS code I use on item page, so maybe it can help you. If you think my code can be improve, let me know here :)
If you have ideas to share, tell me too.
If my English is poor, just let me know too :)


- Replace 123/456/789 for your field ID.
- JS in this box is loaded at the init of the form
- Remember JS can be access with source of the page, so don't use confidential or privacy datas



  • To hide a field with a simple condition (because some kind of input field don't let you to hide the field if empty) :

Code: Select all

value = $('.form-group-123 > td').html(); //if the field is a dropdown list : "$('.form-group-123 > td > div')"
//you can also use the id of the field like : value = [123];
if(value == '') //you also can put "== '0'", or "== 'No'", "!= ''", "== '0,00'" ... depending on your value
{
  $('.form-group-123').hide(); //hide the field
}
  • To hide a field with several conditions (with a dropdown field) :

Code: Select all

type = $('.form-group-123 > td > div').html();
//you can also use the id of the field like : type = [123]; and you need to test the value ID (not the text values) in the array
let tableValues = ["Type 1", "Type 2", "Type 3"]; //array with all text values to check
if(tableValues.includes(type)) //if the field has one of those text values
{
  $('.form-group-123').hide(); //hide the field
}


Hope it can help you :)
Last edited by Didou12 on 13 Jan 2024, 08:05, edited 2 times in total.
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
s980845
Sponsor
Sponsor
Posts: 215
Joined: 03 Jun 2021, 22:06
Name: Bradley Hayes
Location: USA Palmdale
Company Name: Two-Lifestyles, Inc.
Contact:

Re: Some JS code for item/record page

Post by s980845 »

Could you please add screenshots to these examples to help us better understand what they do, and whether they would be a good fit for our own projects?

Thank You.
Didou12
Posts: 487
Joined: 14 Jan 2023, 14:53
Name: Louis
Location: Montreal, Canada

Re: Some JS code for item/record page

Post by Didou12 »

Hi :)

You can have some information in the doc : https://docs.rukovoditel.net/index.php?p=114

Fields on item page, are there to display information (in the column), so you can hide some of them with previous codes, maybe if you field is empty and you don't want to display it, or if the field has a certain value.
Using Rukovoditel since 2022 --- v3.4 (with extension) in French on PHP 8.2
I keep the French translation up to date
I'm trying to help you (+10 years experience in html, css, php, sql, JS/jquery, python)
Post Reply