- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2015 03:47 PM
I need onchange client script to enable /disable button based on state.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// var state = g_form.getValue('state');
if(newValue== 11 ){
var items = $$('BUTTON').each(function(item){
if(item.innerHTML.indexOf('Submit') > -1){
item.hide();
}
});
}
else{
var _items = $$('BUTTON').each(function(item){
item.innerHTML.indexOf('Submit').show();
});
}
}
It fails the behavior.
Thanks
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2015 07:13 AM
I didnt realize your show logic is flawed...
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// var state = g_form.getValue('state');
if(newValue== 11 ){
var item = $$('BUTTON').each(function(item){
if(item.innerHTML.indexOf('Submit') > -1){
item.hide();
}
});
}
else{
var _item = $$('BUTTON').each(function(_item){
if(_item.innerHTML.indexOf('Submit') > -1){
_item.show();
}
});
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2015 08:49 PM
I follow this article
http://www.servicenowguru.com/scripting/client-scripts-scripting/removing-form-buttons/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2015 06:39 AM
Try this
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// var state = g_form.getValue('state');
if(newValue== 11 ){
var item = $$('BUTTON').each(function(item){
if(item.innerHTML.indexOf('Submit') > -1){
item.hide();
}
});
}
else{
var _items = $$('BUTTON').each(function(item){
item.innerHTML.indexOf('Submit').show();
});
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2015 06:52 AM
Issue is button disappear first time but it want show back again.
fails here -
var _items = $$('BUTTON').each(function(item){
item.innerHTML.indexOf('Submit').show();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2015 06:55 AM
try this actually...
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
// var state = g_form.getValue('state');
if(newValue== 11 ){
var item = $$('BUTTON').each(function(item){
if(item.innerHTML.indexOf('Submit') > -1){
item.hide();
}
});
}
else{
var _item = $$('BUTTON').each(function(_item){
_item.innerHTML.indexOf('Submit').show();
});
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2015 07:00 AM
Script error. Because we have declared variable item twice..