Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have the following Javascript code embedded in my side row

window.onload = new function()
{
hideBtns();
}
function hideBtns()
{
if(document.getElementsByName('edit')[0]!=null){
document.getElementsByName('edit')[0].style.display = 'none';}

if(document.getElementsByName('edit')[1]!=null){
document.getElementsByName('edit')[1].style.display = 'none';}
}

Inspecting the edit button in chrome o/p :

<input value=" Edit " class="btn" title="Edit" name="edit" onclick="navigateToUrl('/001d000000JXhAX/e?retURL=%2F001d000000JXhAX','DETAIL','edit');" type="button">

The script is being called , though I see that the name of the "Edit" button is "edit" when I inspect it is not entering the if(document.getElementsByName('edit')[0]!=null){ block !!!

Any pointers will be a great help!!!

share|improve this question
    
Is there a reason you're not just removing the edit button from the page layout? –  LaceySnr Dec 20 '12 at 1:10
    
yes i want to hide the button based on a field value!!! so this is the first part where i want to just hide the button and start putting conditions later –  rao Dec 20 '12 at 1:20
2  
If you want don't want to have users editing a record when a field is a specific value, you could look at locking the record. Here's one way to do that: verticalcode.wordpress.com/2012/07/26/…. –  Daniel Hoechst Dec 20 '12 at 2:52
1  
daniel let me find out if its ok to lock record. sounds nice to do it tht simple, –  rao Dec 20 '12 at 3:13
3  
This should sort you out , probably beat using a Jquery selector with document.ready(), which I tend to rely more on than window.onload tehnrd.com/show-and-hide-buttons-on-page-layouts –  techtrekker Dec 20 '12 at 9:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.