
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2014 06:30 AM
I am trying to hide the submit button on a record producer and I have found several of the various solutions and they do not seem to be working. I found two different pieces of code and when I add alert statements to the code to see the values, both sets of code seems to find something 6 times, but the value of inner is empty so both scripts do not work. Thoughts?
Here is the 2 code samples:
@
function onLoad() {
//get all of the BUTTON tag elements in the document
var refs = document.getElementsByTagName("BUTTON");
//Remove the Submit button
if (refs) {
for (var i=0; i < refs.length; i++) {
var ref = refs[i];
var inner = ref.innerHTML;
//check for the 'Submit' value on the button
if (inner == 'Submit'){
ref.style.display = 'none';
}
}
}
}
or
function onLoad() {
var buttons = document.getElementsByTagName("BUTTON"); //get an array of all the buttons on the form
if(buttons) { //we have some values in the array
for(var i=0; i<buttons.length; i++) { //loop through all of the buttons
var button = buttons[i]; //get the current button from the array
var inner = button.innerHTML; //get the innerHTML from the current array element
alert("inner.toString is " + inner.toString());
if(inner.toString().toLowerCase().indexOf('submit') > -1) { //we found the Submit button
alert('Submit button found');
if(newValue == 'Yes') { //this is the condition under which we'll hide the Submit button
button.style.display = 'none';
} else { //show the Submit button
button.style.display = '';
} //hide the Submit button (else) show it
} //we found the Submit button
} //loop through all of the buttons
} //we have some values in the array
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2014 08:18 AM
A record producer's Submit button in HTML (in Calgary) looks like this:
<a class="request_catalog_button" href="#" onclick="saveProducer(''); return flase;"></a>
I don't see how your two scripts would ever work on this since it is an anchor tag, not a button tag.
Since there is only one instance of the Submit button on the page and it seems to be the only element with the class of 'request_catalog_button', you can hide is like this:
var els = document.getElementsByClassName('request_catalog_button');
//alert(els.length); //alerts 1
els[0].style.display='none';
Just place it in an onLoad.
Which version of Service-Now is your instance running?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2014 07:39 AM
I think the innerHTML on that button is actually " Submit " with spaces before and after. I was able to get this to work in a berlin instance:
var btns = $$('button');
for (key in btns) {
var btn = btns[key];
var inner = btn.innerHTML;
if (inner == ' Submit ') {
btn.hide();
}
}
In calgary that submit button is now an <a></a> but it has a class so you can use that to hide it a bit more easily.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2014 08:19 AM
That still does not work...
I changed the 'Submit' to be ' Submit ' and nothing,
I changed it to say the class name and nothing,
I tried the code you pasted in the answer and it didn't work either.
When I put an alert statement to show the value of inner, inner is blank 6 times and never goes into the "if".
function onLoad() {
//get all of the BUTTON tag elements in the document
var refs = document.getElementsByTagName("BUTTON");
//Remove the Submit button
if (refs) {
for (var i=0; i < refs.length; i++) {
var ref = refs[i];
var inner = ref.innerHTML;
alert("inner = " + inner);
//check for the 'Submit' value on the button
if (inner == ' Submit '){
ref.style.display = 'none';
}
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2014 08:18 AM
A record producer's Submit button in HTML (in Calgary) looks like this:
<a class="request_catalog_button" href="#" onclick="saveProducer(''); return flase;"></a>
I don't see how your two scripts would ever work on this since it is an anchor tag, not a button tag.
Since there is only one instance of the Submit button on the page and it seems to be the only element with the class of 'request_catalog_button', you can hide is like this:
var els = document.getElementsByClassName('request_catalog_button');
//alert(els.length); //alerts 1
els[0].style.display='none';
Just place it in an onLoad.
Which version of Service-Now is your instance running?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2014 08:24 AM
Thank you Justin! That worked! I am pretty new at html stuff, so every little bit helps!