function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Yaswanth KothapalliYaswanth Kothapalli 

Javascript Button Code issue

Hi All,

Is there any changes that occurred in 'setAttribute' and 'getAttribute' javascript functions in Winter 16 release Orgs?
1. Create a 'Detail Page Button' say " Test1 "on any Object, and include the following syntax: 
alert(this.getAttribute('class'));
(or)
alert(this.setAttribute('class', 'btnDisabled')); 

2. Assign the created button " Test1 " to the related page layout of Object. 
3. Click " Test1 "

In Winter 16 Upgraded Orgs, it will throw the error: 
=========
A problem with the OnClick JavaScript for this button or link was encountered:
this.setAttribute is not a function
========
In Summer 15 Orgs,it will not throw the error and works as expected. 

Regards,
Yaswanth K
Best Answer chosen by Yaswanth Kothapalli
Yaswanth KothapalliYaswanth Kothapalli
It was modified as following using JQuery as workaround:
$('input[name=Test1]').addClass('btnDisabled'); 

Not sure why JS has stopped in this release but workaround is to implement the same logic using JQuery.

 

All Answers

JeeTJeeT
Hi Yaswanth,
I am not sure about the change in winter 16 release,
But I have used the following statement for disabling a clicked button.
try using this this.className = "btnDisabled";
Hope this helps you
Yaswanth KothapalliYaswanth Kothapalli

Hi Jeet,

I have tried as mentioned and it does work in Summer 15 org as I said it is not working in Winter 16 org.

Other ways I have tried: 

- getElementsByName('Test1').class='btnDisabled'; 
or 
- this.class='btnDisabled'; 
or 
- var x = document.getElementsByName('Test1'); 
this.class='btnDisabled'; 

None of them works in release Orgs.

Thanks!!
Yaswanth KothapalliYaswanth Kothapalli
It was modified as following using JQuery as workaround:
$('input[name=Test1]').addClass('btnDisabled'); 

Not sure why JS has stopped in this release but workaround is to implement the same logic using JQuery.

 
This was selected as the best answer