How to Disable a Button Using JavaScript

Hi,
I want to disable a button based on a condition. I am using a template based button (button Alternate 3). I am using Theme 3. I have created buttons of type item but when I view the source there is no button name populated in the html. My javascript is not disabling the button.
Please advice.
Thanks
sukarna

Hi,
You can't disable an A tag (FireFox, for example, will still let you click the "link").
What you could do would be to create a second button that doesn't work and only show one of these at a time.
I have done that here: [http://apex.oracle.com/pls/otn/f?p=35917:30]
The Button has been based on a custom Button Template. The definition for this is:
<table class="t10Button" cellspacing="0" cellpadding="0" border="0"  summary="" id="#BUTTON_ATTRIBUTES#">
<tr>
<td class="t10L"><a href="#LINK#"><img src="#IMAGE_PREFIX#themes/theme_10/button_left.gif" alt="" width="4" height="24" /></a></td>
<td class="t10C"><a href="#LINK#">#LABEL#</a></td>
<td class="t10R"><a href="#LINK#"><img src="#IMAGE_PREFIX#themes/theme_10/button_right.gif" width="4" height="24" alt="" /></a></td>
</tr>
</table>
<table class="t10Button" cellspacing="0" cellpadding="0" border="0"  summary="" id="#BUTTON_ATTRIBUTES#_DISABLED" style="display:none">
<tr>
<td class="t10L"><img src="#IMAGE_PREFIX#themes/theme_10/button_left.gif" alt="" width="4" height="24" /></td>
<td class="t10C" style="padding:1px 4px;">#LABEL#</td>
<td class="t10R"><img src="#IMAGE_PREFIX#themes/theme_10/button_right.gif" width="4" height="24" alt="" /></td>
</tr>
</table>This actually creates two buttons - the first one, which actually has the link, is visible to start with. The second one, which has no link at all, starts off as invisible.
Both buttons use the #BUTTON_ATTRIBUTES# setting to get the button name into the ID - though the second button adds "_DISABLED" to this so that it has a unique, but known, ID
Then it is just a case of calling a function to show one button and hide the other or vice versa:
<script type="text/javascript">
function disableButton()
document.getElementById('P30_TEST_BUTTON').style.display = "none";
document.getElementById('P30_TEST_BUTTON_DISABLED').style.display = "block";
function enableButton()
document.getElementById('P30_TEST_BUTTON').style.display = "block";
document.getElementById('P30_TEST_BUTTON_DISABLED').style.display = "none";
</script>Another possibility is to add the #BUTTON_ATTRIBUTES# to the TABLE tag instead of the A tag in a new button template (based on a copy of the normal Button template). Then, the ID value would be applied to entire "button". You can then make this invisible using:
$x('BUTTON_ID').style.visibility = 'hidden';The button will be removed from the page as far as the user is concerned, so they can not click the link.
Andy

Similar Messages

  • How to disable the ribbon using javascript

    when open a PDF document using acrobat X, there is a Tool ribbon in the top right side (there is also a comment ribbon and share ribbon), how to disable or remove the Tool ribbon using javascript?
    I try to use app.listToolbarButtons() and app.hideToolbarButton(...) but not working.
    Any ideas?

    Not possible.

  • How to disable a button using Java Script in Apex

    Hi All,
    I was trying to disable a button when the value of a select list item in the same page is equal to zero. Following are the steps which I did.
    1) Created a new button template as <table class="t9StandardButton" id="#BUTTON_ID#" cellspacing="0" cellpadding="0" border="0" summary="">
    2) Changed the existing button template to the newly created button template.
    3) Added onchange="javascript:fdisplay(this);" to form element value of select list
    4) Added the following java script in the page header
    <script type="text/javascript">
    function fdisplay(some) {
    if (some.value==0){
    html_GetElement ('#BUTTON_ID#').disabled = true;
    else
    html_GetElement ('#BUTTON_ID#').disabled = false;
    </script>
    But the script doesn't work. Is there anything I am missing here. Please advice.
    Thanks,
    Vikas

    Vikas:
    In the 'Button Attributes' field of the button enter 'id='thisButton'.
    Modify the button template to include the substitution string #BUTTON_ATTRIBUTES# . This should be put in the anchor tag in the template defintion.
    Modify your Javascript to reference the above id as
    html_GetElement ('thisButton').disabled = true;
    ....Varad

  • Disable button using javascript

    Hi,
    I'm sorry if this is a relatively simple problem, but I have tried several things and have searched the forum, but still no luck!
    I am trying to get a button in a form to be disabled or hidden on loading the page and only to become enabled or shown once an 'onclick' event occurs. I already have a javascript function running successfully on the 'onclick' event, so there is no problem with that.
    Preferably I would like the button to be template driven, but I realise that disabling/hiding it may only be possible with an HTML button.
    I have tried the following JavaScript, but it appears to do nothing:
    document.getElementById('P6_OK').disabled=true;
    $x_HideItemRow('P6_OK');
    If the JavaScript is ok it is probably the way I am implementing it into the HTML.
    Thanks
    Lucy

    Hi,
    I'm still having troubles with this (see above). If anyone has successfully managed to disable a button using JavaScript I would be interested in how they did it.
    To clarify, I have tried the following two pieces of script, among others:
    (1) document.getElementById('P6_OK').disabled=true;
    (2) $x_HideItemRow('P6_OK');
    I have read quite a few forum links and followed what others have done, but in vain.
    Thanks for your help
    Lucy

  • Hide an HTML button using javascript

    Hi,
    I need to hide an html buttton using javascript. I have an radio button with values "YES" and "NO". If is select NO then i need hide the button without refreshing the page. Can anyone suggest me how to hide an button using javascript.
    Thanks
    Prashanth

    Prashanth,
    The exact solution will vary based on a few factors. The basic idea is to place an event handler on the radio button item that calls a function to hide/show the button. You might also want to call that function when the page loads too.
    If you put an example page on apex.oracle.com and provide the workspace/username/password I'll take a look. You can create a new account for this purpose.
    Regards,
    Dan
    Blog: http://DanielMcGhan.us/
    Work: http://SkillBuilders.com/

  • Associating two events with submit button using  javascript in jsp

    Hi
    How can i Associate two events with submit button using javascript in jsp. Firstly it should insert the data to database and secondly it should close the same pop-up window

    Have something like :
    <input type="submit" name="submitbtn" value="Click me" onClick="function1(); function2(); " />
    You just call both functions sequentially, it's that simple. Although using javascript to work with a database, that seems a bit tricky.

  • How to disable Setting button in Tools - Options - Advanced - Network from windows registry?

    Dear support,
    Now, my office use Firefox as default browser to access WebServer. And there are some policy that users must use ProxyServer. I do not want user change proxy setting in Firefox. How to disable Setting button in Tools - Options - Advanced - Network from windows registry?
    Thank you.
    Treky

    You can not use the Windows registry to disable items in Firefox. This link shows how to lock down Firefox proxy settings, change the values to suit your needs:
    http://www.stbernard.com/ip5kb/iPrism/WhatsNew/50SupportFiles/SupportFiles/IP0460.htm
    One minor variation, in step 4 instead of adding that line to all-js, you can create a file called ''local-settings.js'' containing the line shown and save the file in the same folder as all.js

  • How to disable the button in application toolbar in report pgm

    Can anyone help with How to disable the button in application toolbar in report pgm

    Hi,
    You can use it_excluding to disable button on the tool bar.You have to find the function code for the required button and append that function code to the it_excluding .The optional IMPORTING parameter IT_EXCLUDING is an internal table. It is only needed if the caller uses the list tool standard interface but wants to deactivate interface functions which he or she does not need.You can have your defined pf-status using I_CALLBACK_PF_STATUS_SET.
    SAMPLE PROGRAM
    tables spfli.
    type-pools: slis.
    DATA W_FCODE TYPE SLIS_EXTAB-FCODE.
    data: t_spfli TYPE SPFLI OCCURS 0 WITH HEADER LINE.
    select * from spfli into table t_spfli.
    data : t_excluding TYPE SLIS_T_EXTAB .
    W_fcode = '&OUP'.
    append w_fcode to t_excluding.
    W_fcode = '&ODN'.
    append w_fcode to t_excluding.
    call function 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_STRUCTURE_NAME = 'SPFLI'
    IS_LAYOUT =
    IT_FIELDCAT =
    IT_EXCLUDING = T_EXCLUDING
    tables
    t_outtab = T_SPFLI
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2.
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/99/49b844d61911d2b469006094192fe3/frameset.htm
    Regards,
    Priyanka.

  • How to disable minimize button(icon) of jframe

    how to disable minimize button(icon) of jframe

    HELP!
    I need to do a similar thing. Along with a couple other things.
    I was able to control some windows thru a unix window manager like I would for Motif (the use the window name of AWTapp or AWTdialog are recognized when doing xwininfo) That is all I can seem to get. Nothing changes this.
    Does anyone know how?
    Anyway. mwmDecorations and mwmFunctions settings appear to allow setting of some of the windows. But I need control 100%of the time.
    I need to disable the CLOSE button in all java windows or find a way that the window manager event can get back to the java application. Currently it is not recognized.
    In some windows I need other items disabled such as SIZE & MAXIMIZE.

  • How to disable hold button in purchase order creation.

    hi
    how to disable hold button in purchase order creation.

    Select single * from VBAK where clause
    ---It fetches single record from the database, based on the condition you specified in the where clause.
    Where as select * from VBAK up to 1 row
    ---Fetches first record if the condition specified in the where clause is satisfied, otherwise it doesn't fetch any record

  • How to disable 'display pdf (using Acrobat Pro X) in browser'?  Note:  The option is unavailable to un-check box.

    How to disable 'display pdf (using Acrobat Pro X) in browser'?  Note:  The option is unavailable to un-check box.

    Hi URT301,
    Please see this document: PDF Ownership when Reader X is Installed with Acrobat. You'll find several solutions to this problem in the FAQ section.
    Please let us know how it goes.
    Best,
    Sara

  • How to disable save button on selection screen (1000) run from other report

    Hi Experts,
    Can any one let me know how to disable save button on selection screen (1000) run from other report.
    Say I am running from report R1 which submits report R2, but the save button should be disabled on
    report R2(selection screen 100).
    Thanks in advance.
    Regards
    RP.

    Hi RPReddy16 ,
    Try this:
    DATA :BEGIN OF t_extab occurs 0,
                     fcode like rsmpe-func,
                 END OF t_extab.
    REFRESH T_EXTAB.
    MOVE 'SAVE' TO T_EXTAB-FCODE.
    APPEND T_EXTAB.
    CLEAR T_EXTAB.
    SET PF-STATUS 'STATUS' EXCLUDING T_EXTAB.
    Regards,
    José

  • How find the missing glyph using javascript [like indesign preflight], and replace same glyph available font or

    The situation:
    I want to use basetext font, but some of the glyphs are missing in it, and are highlighted with pink boxes. common font [stix, etc.] have much more glyphs than basetext font. I can apply common font [stix, etc.]manually for each of the missing glyphs or insert two character and use kerning set it up, but it is tedious.
    Question:
    How find the missing glyph using javascript [like indesign preflight], and replace same glyph available font or insert two character and use kerning set it up?
    Any one know how to do this?
    Thanks in Advance,
    ~Jack

    Try Peter kehrl's script
    http://www.kahrel.plus.com/indesign/missing_glyphs.jsx

  • How to disable Setting button in Tools - Options - Advanced - Network..i've read an article that solved this problem..but thats problem contains web adress that couldn't be opened..any other solution??? thanks before best regard

    How to disable Setting button in Tools - Options - Advanced - Network..i've read an article that solved this problem..but thats problem contains web adress that couldn't be opened..any other solution???
    thanks before
    best regard
    -ariansyah-

    You can disable or remove that button, but that won't prevent users from making the changes on the about:config page directly.<br />
    You can lock the related network.proxy prefs if you do not want users to change the connection settings.
    See:
    *http://kb.mozillazine.org/Locking_preferences
    * http://kb.mozillazine.org/network.proxy.type
    * http://kb.mozillazine.org/network.proxy.%28protocol%29
    * http://kb.mozillazine.org/network.proxy.%28protocol%29_port

  • How To Disable Delete Button on AR Customer Search

    hi Guru,
    How to Disable the Delete Button of AR Customer Search Form.

    Hi;
    Duplicate post, please make post once
    How To Disable update Button on AR Customer
    Regard
    Helios

Maybe you are looking for

  • Need to find the time spent based on condition

    Post Author: EarthMover CA Forum: Formula Employee Name   Problem Description         Condition   Time                         Alder, Harrison     10W Hydraulic Tanker       ACUP       2/18/2008 1:34:46PM Alder, Harrison     10W Hydraulic Tanker     

  • Error: the specified resource is reserved.

    Hi all, I have composed a program that is going to read 4 analog input voltages, however, I get error as shown in the picture.  Basically, Dev1/ai0 thru Dev1/ai3 will be used to get data from. But everytime I run this program, one of the DAQmx reads

  • Gaming Precautions with Early 2008 MB

    Hey Everybody! I had a couple questions that I can't seem to find definitive answers to anywhere else concerning playing games on my 2008 2.4 GHZ 2 GB 13' MB. I've used it mostly for school, music, photos, and movies, so playing games is a whole new

  • Tuning Issue between 2 queries...

    Hello ; the first query is select prog, at_pck.y(prog) z from (select distinct prog from x where stat = 'oracle'); execution time is like 0.1 sec when i modify the query above like that; select k.prog from (select distinct prog from x where stat = 'o

  • Change default number of received calls in N95

    Hi, My N95 keeps a short list of received calls, while I would like to increase the number. Can it be done? Ran