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

Similar Messages

  • How can we prevent back button  using java script

    how can we prevent back button using java script

    Would be quicker for you to google for javaScript
    javascript:window.history.forward(-1);

  • How we close Views without using Java Script

    Hi All,
    can you please suggest me how i close view with out using java script.
    if possible please reply with code.
    Thanks
    Siva

    Hi Siva,
    You can do this either by hiding your window or by closing the window. Following is the sample code to do that
    IWDWindowInfo windowInfo = null;
    IWDWindow window =null;
    windowInfo = (IWDWindowInfo)  wdComponentAPI.getComponentInfo).findInWindows("<<WindowName>>");
    if(windowInfo!=null)
    window = wdComponentAPI.getWindowManager().createWindow(windowInfo,true);
    window.hide();
    Try with this code, might be useful for your scenario.
    Thanks,
    Sandeep

  • How to generate Serial numbers using JAVA SCRIPT

    how to generate serial numbers(incrementing by 1) using JAVA SCRIPT
    thanking you,
    pola pradeep

    i am afraid that whether ur looking for this. bcoz its a simple for loop
    <script language="JavaScript">
    //count = limit value for u
    for(i=0;i<count;++i){
         alert(i);
    </script>
    or if ur looking for something else, pls mention ur requrment precisely
    aleena

  • How to create a class using java script..

    Hi all,
    Iam new to java script and I tried out the following program but its not working..I basically created a class just like a java prog' but Iam not getting any output or error.Iam attaching the code below.
    If I created one function inside the script and create one object its working fine but what should I do when I have a lot of function??so I created a class and put all the function and created an object but its not working..
    Do let me know what changes should I do..Iam attaching the code which I had written. or give me an example of how to create a class with couple of functions using JAVASCRIPT
    Thanks
    Avis_su
    <html>
    <head><title>JSP Page</title></head>
    <body>
    <SCRIPT language = "JavaScript">
    <!--
    //Created classes
    class book
    var title: String;
    var author:String;
    function author()
    doucument.write("Author is " +this.author);
    function tile()
    doucument.write("Title is " +this.title);
    function printall()
    var counter = 0;
    function author();
    function title();
    var chapters = Array[String];
    for(chapter in this chapters)
    counter++;
    document.write("Chapter" counter" :"+this.chapters[chapter]+"<br>");
    var thisbook = new book()
    thisbook.author = "Sivagami";
    thisbook.title = "MS in CS giude";
    thisbook.chapters = new Array[10];
    thisbook[0] = "Prepare to Excell in all ";
    thisbook[1] = "Learn to be happy";
    thisbook[2] = "Learn to be healthy mentally emotionally physically";
    thisbook[3] = "Siva and Subbu along with kidssssss will be successful in future";
    thisbook.printall();
    //-->
    </script>
    </body>
    </html>

    Run this program to get your answer:
    public class AnswerToYourPost {
    public static void main(String args[]) {
    System.out.println("TRUE/FALSE: This question
    ion belongs on a Java forum.\n"
    + "ANSWER: " + ("Javascript" == "Java"));
    }Since when do we compare objects for equality using operator == ?

  • How to add control buttons using Java thorugh serial port?

    Hi everyone,
    I'm new to this forum.
    I have some questions on Java and serial port.
    I want to write a Java program to control my robot, through serial port. For example, when I click "Forward", the robot will go forward, and so on.
    Now I already have the buttons, so next I would like to ask how to interface the buttons with the serial port.
    I already have all the javax.comm things installed.
    below is the code for my buttons:
    import java.awt.*;
    public class ControlButtons extends java.applet.Applet
         GridLayout myLayout = new GridLayout(3, 3);
         Button button1 = new Button(" ");
         Button buttonForward = new Button("Forward");
         Button button2 = new Button(" ");
         Button buttonLeft = new Button("Left");
         Button buttonStop = new Button("Stop");
         Button buttonRight = new Button("Right");
         Button button3 = new Button(" ");
         Button buttonReverse = new Button("Reverse");
         Button button4 = new Button(" ");
         public void init()
              setLayout(myLayout);
              add(button1);
              button1.setVisible(false);
              add(buttonForward);
              add(button2);
              button2.setVisible(false);
              add(buttonLeft);
              add(buttonStop);
              add(buttonRight);
              add(button3);
              button3.setVisible(false);
              add(buttonReverse);
              add(button4);
              button4.setVisible(false);
    }Now I would like to ask for direction on how to add in the code to make it work with serial port.
    Thanks

    The plan is, I have a robot device connected to the serial port.We don't know anything about that device. We don't know how to control it. We don't know what you have to write to the device to make it do anything. Only you know what.
    For example, when I click "Forward", the robot will go forward, and so on.So what do you have to send to make it do that? and same for the other buttons.
    Next, you need to work out from the javax.comm API how to open the serial port and send data to it. This is a standard exercise in learning a new API. You must be able to do this. Again and again.
    But the program is useless. The button can be clicked, but didn't do anything.Because (a) they have no ActionListeners and (b) there is no code to send anything to the serial port.
    You have to write all that. So you also have to look up ActionListener in the Java API and how to attach it to a button. You can do that. We all do that kind of thing every day.
    So next I would like to ask how to interface the buttons with the serial port.You've been asking nothing else since you started, but you've also only done enough investigation of your own to create the buttons. That's only the start.
    The problem is what method and command should I use to make those buttons actually functioning.See above. You've been told part of it several times. The rest only you can answer, because it's your robot.

  • 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:
    &lt;table class="t10Button" cellspacing="0" cellpadding="0" border="0"  summary="" id="#BUTTON_ATTRIBUTES#"&gt;
    &lt;tr&gt;
    &lt;td class="t10L"&gt;&lt;a href="#LINK#"&gt;&lt;img src="#IMAGE_PREFIX#themes/theme_10/button_left.gif" alt="" width="4" height="24" /&gt;&lt;/a&gt;&lt;/td&gt;
    &lt;td class="t10C"&gt;&lt;a href="#LINK#"&gt;#LABEL#&lt;/a&gt;&lt;/td&gt;
    &lt;td class="t10R"&gt;&lt;a href="#LINK#"&gt;&lt;img src="#IMAGE_PREFIX#themes/theme_10/button_right.gif" width="4" height="24" alt="" /&gt;&lt;/a&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
    &lt;table class="t10Button" cellspacing="0" cellpadding="0" border="0"  summary="" id="#BUTTON_ATTRIBUTES#_DISABLED" style="display:none"&gt;
    &lt;tr&gt;
    &lt;td class="t10L"&gt;&lt;img src="#IMAGE_PREFIX#themes/theme_10/button_left.gif" alt="" width="4" height="24" /&gt;&lt;/td&gt;
    &lt;td class="t10C" style="padding:1px 4px;"&gt;#LABEL#&lt;/td&gt;
    &lt;td class="t10R"&gt;&lt;img src="#IMAGE_PREFIX#themes/theme_10/button_right.gif" width="4" height="24" alt="" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;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:
    &lt;script type="text/javascript"&gt;
    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";
    &lt;/script&gt;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

  • How to access sql server using java script

    Hi, Is it possible to connect to sql server in java script. I'm using microsoft jdbc driver for connectivity to sql server.
    Thanks

    Hi, Is it possible to connect to sql server in java
    script. I'm using microsoft jdbc driver for
    connectivity to sql server.If you want to ask about Javascript, you are in the wrong place. Go and find some JavaScript forum. Actually, you could connect to database from javascript using Ajax or the like mainly because you could have Java code behind the scenes, but then that too is not something I would want to discuss here. So, go find the correct place for the topic.

  • How to Change Paper Type Using Java script

    HI ,
    We have a requirement , in which we have to change the paper type i.e. "A2" , "A3","A4" etc.  while printing using a JavaScript. I have written a code like this :
    xfa.form.form1.pageSet.Page1.medium.stock = "A2"; But this is not working. please help me out.
    Thanks,
    Bhaskar.

    That's the right object for choosing the page size at Design time. What event are you doing this on? Although you can change it in the form model, the form's page size is already determined from the template by the time you have a form to script against, so although you can change it via script after the fact in XFA, I don't believe it will have any impact. Even putting it on the layout ready event does not work.

  • How & where to use Java script to create new button in object detail page

    Hi All,
    I want to create "New/Add button" in object detail page. If i am not wrong i need to use java script for that but could you please let me know how & where to use Java script to create new button in object detail page in CRMOD.
    Thanks in advance.
    Regards,
    Manish

    Any related object on the detail page should have an "Add" or "New" or both buttons by default - This is vanilla functionality and will do the required action.
    If you want to modify this behaviour and do something tricky you will potentially have to go for javascript. You should add the javascript on a custom web tab on that Object.
    Admin --> Application Customization --> Contact -->Contact Web Applet
    Now, add your javascript in the code area, after you select the type = HTML for this web applet, expose this web applet on the Contact detail layout and your javascript will be invoked whenever this page is loaded.
    Check this online document to see how javascript can be embedded in CRM on Demand http://helponmyproject.com/TTOCOD/
    Cheers!
    Royston

  • How to pass values to variables in WAD 7.0 using java script

    Hi.,
    My requirement is based on WAD 7.0.
    The sales value has to displayed in WAD using graph with various chart types.
    I have created variables for plant and material group in a query.
    I have created drop down box for plant with all plants in it, check box for material group and a Submit button in WAD in FORM tag of HTML coding.
    Once all the values are set in drop down box, checkbox and if the user clicks on submit button, the values has to captured by the variables for which I have created and the graph has to be aligned to the new values in variables.
    Kindly help me how to use java script to get the values from FORM and pass it to variables.
    Regards,
    Selva

    Hi Selva,
    You do not need to use Javascript for this. Instead you can achieve this by using API Commands in WAD 7.0.
    Please configure Action on the ButtonGroup webitem to use 'Commands'.
    ->Choose Command 'Set Variables Values / SET_VARIABLES_STATE' under Commands for Web Templates
    ->Set Display Variable Screen setting to OFF
    ->Choose Query Variable for Plant, Select Variable Type as 'Binding Type', Binding Type as 'Data Provider Selection', Data Provider as the one you have assigned to the Dropdown webitem, Characteristic as 0PLANT or as that assigned to the Dropdown webitem
    ->Repeat above steps for Query Variable Material Group
    Now when you make a selection from the Dropdown webitems, the Chart output will change accordingly. Let me know if this helps.
    --Priya

  • How to detect whether browser's java script  disabled or not from server

    How to detect whether browser's java script disabled or not from server side

    I would use a hidden parameter created by a javascript. if this is null, javascript is disabled...

  • How to  build a  Calculator in WAB Template  by using  Java Script......

    Hi ,
    I am  trying   to build a dynamic  calculator in WAD which is as  similar to one in Executive view in Cognos. The  problem i am  facing  is,  i can  able to build a normal  calculator  by using  java script  but  i am  unable  to read the  key figure  values from  the  analysis  item  on from the  data  provider  in to  by  calculator  by using  on click  function. I wanted  to get the all  the  values in to a internal excel , so  that  my calculator can read the  values from  that. can  any  one  help  me  on getting  values in to internal excel by using   java before the  executing the  web template ?...
    Thanks in advance....
    Jhon.
    Edited by: sap bw on Jul 31, 2008 5:51 PM
    Edited by: sap bw on Jul 31, 2008 5:52 PM

    I might not be understanding your question completely since you mention WAD and then Excel, but if you are asking how to get the key figure values using Javascript in WAD, you can go to the Dataprovider properties and enable 'Output Result Data'.  This will embed an XML element into the HTML output that you can then parse using standard Javascript DOM navigation.
    Hope this helps.

  • How to get the context data using java script in interactive forms

    Hi All,
    How to get the context data using java script in interactive forms by adobe,  am using web dynpro java
    thanks.

    Hi venkat,
    Please Refer this link.
      Populating one Drop-Down list from the selection of another Drop-down list
    Thanks,
    Raju.

  • How to do Front End Validation for JSP Forms using Java Script with 9iJD...

    How to do Front End validation using 9iJD. Any wizard is there. We need to do the val. using Java Script. If its not available, please include that in the Production Release.

    Thanks a lot. When is the Production Release is scheduled. Please tell us whether itll be available for Free Download. Bec, we couldnt buy. Bec, if its working fine with all the options without any bug only, we can ask our company to buy 9iJD by stating the advantages. Just explain us.

Maybe you are looking for

  • Can you associate a note with a To Do in iCal?

    I'm struggling to make sense of Apple's Notes and To Do functionality. I know I can create a note or a to do item in Mail, and the to do's will show up in a special calendar in iCal. I'm fine with that as it's a somewhat similar model as Outlook, wit

  • Apple TV 1st Gen not syncing

    I've been using my ATV (1st Gen) for years, but shortly after I installed iTunes 10.5 I can no longer sync it. I tried everything, I even reset to factory defaults, re-installed itunes, reboot router (D-Link DIR-825). My computer (Windows XP) and the

  • Print out

    Helo SAP Experts, Kindly help me for the following Print outs in SAP. Tell Me how to do in SAP? 1) Purchase Requisition 2) Request For Quotation 3) Purchase Order 3) Price Comparison Print out 4) Goods Receipt Note It is very urgent requirement for o

  • Does anyone know the technical specifics of the GPS receiver in the iPad2?

    I have an iPad2 that I use in the aviation community and I am trying to learn the technical specifics of the GPS receiver in the 3G iPad 2, i.e. sensitivity, how many satelites does it receive concurrently, what level of accuracy is used to measure i

  • The iPhone could not be restored. An unknown error occured (2)

    I'm trying to restore my iPhone 3G, but everytime I try to restore it it comes up with the error code 2. I looked up in Apple, and it says that I can fix it by removing AntiVirus software, so I removed my AVG and temporarily turned Windows Firewall o