
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2015 06:30 AM
I'm trying to grab an element by it's class name in a client script (Dublin) with
var mand = document.getElementByClassName('mandatory');
How ever this falls over with the error...
"TypeError: document.getElementByClassName is not a function"
Any thoughts why this is happening?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2015 06:32 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2015 06:31 AM
This is the whole script
function onLoad() {
var closeCode = String(g_form.getValue('u_closure_code'));
if(g_form.getValue('state') != 1){
g_tabs2Sections.setActive(1);
g_tabs2List.setActive(1);
}
alert('pre mand');
var mand = document.getElementByClassName('mandatory');
alert(mand);
if(mand.style.indexOf('visible') != -1)
{
if(closeCode != '' && closeCode != 'perfect_change'){
g_tabs2Sections.setActive(2);
g_tabs2List.setActive(1);
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2015 06:32 AM
How about 'getElementsByClassName'? I think it needs to be plural.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-20-2015 06:34 AM
That's the one, cheers Mark I'd completely overlooked that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2017 10:09 PM
Hello,
I had simmiliar requirement.
Goal was to not display ticket number in the form header until ticket wasnt created -
Target was to hide ticket number in the form header, img below
First I viewed source code of HTML page and found div ID and all other relevant div class names that were under main DIV. When I had that information, I was able to hide different elements under the div, script is below
It was OK for me to put script in to UI policy and run script for new records only - this was requirement
Thru UI policy, number field was also hidden by common UI policy approach
Thru this approach (script below) you can easily have under control full screen. What you need to know is just div id and relevant class name , then you can do styling as needed.
hope this helps
/Petr
// Get the element with id="incident.form_header" (a div), then get all elements inside div with class="navbar-header"
var x = document.getElementById("incident.form_header").querySelectorAll(".navbar-header");
// Set the visibility of the first element with class="navbar-header"
x[0].style.visibility = "hidden";