Using JavaScript - hide/show a page element

Environment:

APEX 3.1.00.09 on AIX 5.3

Sample application on apex.oracle.com:

Workspace: GALWAY
Username: gwicke
Password: gwicke

To see where my questions are:

1 - Start on page 3
2. in the Agency drop-down select 'J & B Marketing'
3. in the contract drop down select the only contract that appears
4 - Click "modify existing contract.
5-note the "LY closures" page element has the value 261
6 - click on the link (really a tab in my theme) at the top labeled 'full cost '.
7 - the "Justification for estimate" is the page element to be displayed/hidden which is noted below.
8 - "houses by year" under the column "Year1" is of the order of the day of the user entry page
9 - the P2_BUILDER_CLOSINGS (261 above value) is the page element that you want to use in the comparison

I need to do a few things with a potentially hidden page element:

1 - everytime the page loads, I need to check if the page element (P8_ESTIMATE_JUSTIFICATION) is not null, and if it is indeed not null, make displayed.

2. when the user enters a value in another element of the page (P8_HOMES_PER_YEAR1), call a function to see if the value is greater than 120% of another element on the page (P2_BUILDER_CLOSINGS) and if yes do this question page (P8_ESTIMATE_JUSTIFICATION).

I have the function created javascript (showHideEstimateJustification) and in the HTML of the page header. Currently, the function is called with a cheque for onChange on the item page entered by the user as described above (P8_HOMES_PER_YEAR1).

Questions:

1. I need to force a SHIPMENT once the user enters the value of P8_HOMES_PER_YEAR1 is available in session state and so the function javascript (other ideas welcome!)

2. I am currently using the x.style.display = 'inline' versus 'none' to hide and show the page element, where x is derived from var x = document.getElementById (P8_ESTIMATE_JUSTIFICATION) y at - there a better way?


Any help is greatly appreciated.

-gary (aka Javascript newbie)

Hello

Ok.

An HTML tag is an object - TABLE, TR, DIV, SPAN, INPUT are all objects. Identify us these objects giving them IDs. An object consists of many different properties. Any time we want information on an object we call javascript by saying it the object, we want to know something and the property we want to know. Thus, if var g you, g.name would be "Gary" and so on.

No matter when you need information about an object, you can point a variable to it by referencing its ID - var g = document.getElementById("GARY"). var g then lets get all the information I need and, in many cases, update information on the object. var gh = g.style.height var g.value = gValue GOLD and so on.

Sometimes, however, all you really need is the 'value' of this object, so you can just do - var g = document.getElementById("GARY").value

So, if you need a bit of information, to set a variable to object.property, but if you need more than one, set the variable to the object itself. Setting the variable to the object is something unique, so is generally faster than the reference to each property using document.getElementById("GARY").value inside and so on - as javascript should start at the top of the document, search for the specific object and then find the property.

The confusing thing, I think that, coming from a programming, is that each variable is defined using "var" instead of an object type explicit

OK, back to your page...

Earlier, we have changed the javascript code to use:

var closings = &P2_BUILDER_CLOSINGS.;

and Apex would replace & P2_BUILDER_CLOSINGS. with a value, for example, 261, so when the page is rendered, the script actually shows:

var closings = 261;

Thus, it is digital already. If this part is ok.

The element "homes" but must be converted to a number by the parseInt() function. The fact that you see "NaN" (which is, as you say, a shortened version of 'Not a number'), means that the value it is to see is not numeric. If the first test would be to add an alert message () to display the value of document.getElementById('P8_HOMES_PER_YEAR1').value. It is likely that non-numeric characters are entered? There may be problems with commas or currency symbols

Andy

Tags: Database

Similar Questions

  • Captivate: Using Javascript to show/hide captions text

    Hello

    I want to show/hide a legend of text using javascript. I can't find the way to do it with advanced actions. I don't know if it's because it belongs to a question slide in a pool. Anyone know if this is possible and how this can be done?

    There is nothing wrong with your English - no need to apologize :-)

    I just tested it. Seems to work for me to create a tip action that will show my custom legend if I set a variable of personalized tour. Rather than xplain, I have attached a word with some screen shots doc and an example of file CPTX. File is Captivate 5, but even should work in 5.5

    Steve

  • How to use the value of the page element in other pages too?

    Hi all

    How to pass the value of the item P26_NO from 26 to all other pages (such as 1, 2, 3... 25) using the & P26_NO. ???
    I set the default for this item.but I can't able to find value in the session state itself?

    Please post your suggestion here!

    Thank you and best regards,
    Robette.

    Robette wrote:
    Hi Amelia,.

    Through application process only we can able to save the page element value in session state? is there another way?
    Since my requirement is like I need to display footer text in all the pages, I have the version number included in this text, so I created a table and my intention to create an item and passing the point value for all other pages and see that point value & P26_NO. in the text. Version number is dynamic, it will change at each deployment.
    Is another way simple, other than my approach?

    Thank you best regards &,.
    Robette.

    You should use point demand for it and an application process to fill

    IF :APP_ITEM_NAME IS NULL THEN
      APEX_UTIL.SET_SESSION_STATE('APP_ITEM_NAME','myvalue');
    END IF;
    

    Published by: VC on June 25, 2012 13:48

  • How to hide/show the individual elements in a document

    I try to hide all items in a document (and store each original visibility state), iterate the elements preselected user and perform an export for each item in the selection (I've got this covered part) and finally restore the visibility of each new item state (where the initial visibility state storage is necessary).

    I found that I can browse all the elements in the document to help

    app.activeDocument.pageItems[i]
    

    where i is the page element identified by the index of the i - th in the pageItems collection.

    What is not clear, however, is how to get the visibility of this element of the page state. Indeed, there is a visbilityVariable of property associated with the elements of the page, but when I try to 'control' the content with an alert message, I get "undefined".

    Is there the best ways through all elements in a document? Ideally, I would like all the elements of access regardless of the weather, they are elements of the path, group items, items of text frame or what have you. I need this collection in the State of visibility of each item read/write. Thank you!

    "visibilityVariable" is for "data-driven graphics", regardless of those who may be. Try the property 'hidden' instead.

    JoarBolstad wrote:

    Is there the best ways through all elements in a document? Ideally, I would like all the elements of access regardless of the weather, they are elements of the path, group items, items of text frame or what have you.

    Don't worry, you got it right first time. 'PageItem' is the global superclass of all the graphic elements. Starting from the ESTK help (rather, my version as well):

    PageItem class
    A page element object.

    Superclass of CompoundPathItem, GraphItem, GroupItem, LegacyTextItem, MeshItem, NonNativeItem, PathItem, PlacedItem, PluginItem, RasterItem, SymbolItem and TextFrameItem

  • Dynamically hide show Page elements

    Dear all,
    Im tring to dynamically hide and show the page element. I searched and found something but it does not work for me. IM using apex 4.1 and below are described the work I've done.

    I have 5 fields iitems in my page (form).

    -The Customer No.
    -Edit
    -First name
    -First name
    -Address

    I want to hide the name, surname, address, based on the value to change. Let's say if the user selects "name Edit" then name must obtain visible while name & address hidden.

    So I put this line onChange = "$f_Hide_On_Value_Item(this,'LASTNAME,'LN')" in the point EDIT page > Label > HTML table cell attributes "

    But it does not not for me? Where am I wrong?

    Thanks in advance.

    Have you seen the documentation? http://docs.Oracle.com/CD/E23903_01/doc/doc.41/e21676/javascript_api.htm#CHDHIAJB

    I suggest you to use actions Dynamics http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21674/advnc_dynamic_actions.htm#HTMDB27020

  • Hide region show how to maintain the status of hide/show on send page

    APEX 4.2.1 using theme 24

    I have several areas on a single page that are defined using the "Hide Show Region" model this model defines the regions to show everything first. If a user chooses to hide a region is there a way to keep this state when the page is submitted? Example region top of page is to hide/show parent to an interactive report, below this area is a relative of region to hide/show for a tabular presentation, if the user chooses to hide the interactive report region and they enter data in the region in a table, when he clicks on save and the page is submitted the interactive report region appears and the tabular form region appears still longer down in the page and the user have to scroll down to access.  I'd rather have the page 'to remember' the State of hide/show that the user has selected for each region and keep this status when the page is sent.

    Someone has an idea how to do this?

    Thanks in advance for a suggestion to work!

    Theresas

    You have almost all the way.

    As you have probably already understood, the problem is that the code requires that regions begin closed and it will 'click' to open.  If you're one of them is already open, you have now two inverse regions.

    I think that it is better to have them both be areas closed, when the cookie should be created (we were a new cookie for that) then "click on" one you want to open and create the cookie with this region in.  From that moment of the code can continue to click on the one that was left pending.

    So, I added more code to the initial opening. I introduced the P2INIT cookie which will be set to YES the first time the page is visited.  Its only purpose is to open the region to report on the first visit.

    After that, the logic can circulate to store regions that can be opened.

    Also, I have completed the static ID of the report to better reference by name.

    Now, I have to say, if you are presenting the same data, but a game is available to edit in a tabular form, something like Page 3 would work?

    When you click on edit the grid it will hide the report and view the form in a table. When you click 'View report' he hide the form tab and view the report.

    I think it's a clean approach and the data are not queried the DB double. It also avoids the flicker of the openness of the region.  Just an idea.

    I use preferences instead of cookies.  The nice thing about the preferences, it's that they are saved in the DB for the user, so if the same user logs on to another computer or a browser preference comes with them.

    Thank you

    -Jorge

  • How to use javascript to go to different pages?

    I use javascript to pop-up a message box with selection or not.

    If the user select Yes, and then I want to go to page 10.
    If the user select No, and then I want to go to page 12.

    How to use Javascript to control which pages to go?

    Thank you.

    Now, I need to get the values of entries in the list.

    What are the values that you need to get your entries in the list?

    Can you post JS and what you're trying to do?

    Kind regards
    Hari

  • Show or hide the buttons of the model using JavaScript

    Can someone tell me to know to disable, show and hide the buttons of the model using JavaScript? In my case, I use AJAX for validation and the validation failed, I want to deprive the person's ability to submit the form. I did successfully using the HTML buttons but they seem ugly and do not correspond to the theme of the application. I really want to do using the model based buttons. Anyone know the answer to that?

    You can find that here:

    http://Apex.Oracle.com/pls/OTN/f?p=31517:143

    The only problem you have to solve is to assign an id to each template button. Rather than use an id string coded hard = "buttonHide1" as in my example, you could use id = "" #LABEL # "If there are a lot of different buttons you need to display / hide on a single page." However, at the same time make sure that the processes are also conditional and follow the logic. To hide a button, this isn't a guarantee that a process can not be executed.

    Denes Kubicek
    -------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    -------------------------------------------------------------------

  • You want a javascript redirect URL using a previously defined page element?

    Hello
    I have a button where I set up a redirect to the URL option and you use: javascript:html_PopUp('http://yahoo.com',_'_newwindow').

    It's pretty clear, and it works. I also have a defined page element that contains a valid URL
    For example: P4_OFFICE_WEB_PAGE_LINK_V: = 'http://google.com '.

    I want the pop up to use a stored value, not the hardcoded hard a top... I tried all these, but none seem to work:

    JavaScript:html_PopUp('P4_OFFICE_WEB_PAGE_LINK_V',_'_newwindow');
    JavaScript:html_PopUp(':P4_OFFICE_WEB_PAGE_LINK_V',_'_newwindow');
    JavaScript:html_PopUp(APEX_UTIL.) GET_SESSION_STATE ('P4_OFFICE_WEB_PAGE_LINK_V'), '_newwindow');

    What should I use?

    Thank you.

    Hello

    Try

    javascript:html_PopUp('&P4_OFFICE_WEB_PAGE_LINK_V.', '_newwindow');
    

    Kind regards
    Jari
    -----
    My Blog: http://dbswh.webhop.net/htmldb/f?p=BLOG:HOME:0
    Twitter: http://www.twitter.com/jariolai

  • How to hide the textfield element using javascript

    I point textfield and I want to hide it using javascript...

    can you help me please?

    Hello

    I checked his works well for me.

    Go to DISPLAY ATTRIBUTES and change the direction of cursor to DO NOT FOCUS CURSOR

    then check...

    Let me know incase of any concerns.

    See you soon,.
    Shan...

  • Hide/show the area, keep the value between pages?

    Hello

    I use APEX 3.2.1 with Oracle 10 g on Windows XP Pro SP3.

    I have 2 menus (regions) that can be hidden or shown by clicking on an image (as in some IDE). The following javascript code is called on the event 'onClick ':
    function visibilite(region,image) {
         if (region.style.display == "none")
              region.style.display = "" ;
         else
              region.style.display = "none" ;
         if (image.src.indexOf('gauche.png',1) == -1)
              image.src = image.src.replace('droite.png','gauche.png');
         else
              image.src = image.src.replace('gauche.png','droite.png');
    }
    It works perfectly, but when I navigate to another page, the menus are obviously displayed by default...
    So, I just want to keep the value of the previous page to show or hide my menus in the current page.

    I can add the page element in all pages and assign the value using the url, but it is not optimized as I will have a lot of pages (> 100).
    I can use a request element too, but I tried and I can't assign a javascript value, and I don't know if this is a good solution because it will force I call the javascript function, just after that the menu will be displayed, to hide quickly.

    anyone think of another solution?

    Thank you.

    Yann.

    I can add the page element in all pages and assign the value using the url, but it is not optimized as I will have a lot of pages (> 100).

    Create a Page 0 item which will be available on all pages.

    OR

    I can use a request element too, but I tried and I can't assign a javascript value

    Enforcement point values can be set from JavaScript using AJAX and an application process.

  • Hide/show items based on another point when the page is rendered.

    Hello

    I am trying to hide or display the elements on the page when the page is rendered according to the value of a checkbox control.

    That's what I use.

    Body HTML attribute:

    OnLoad = "initialCheck (); »


    Header HTML:
    function initialCheck () {
       if (html_GetElement('P21_BEN_SAVINGS').value != 'YES') {
          html_HideItemRow('P21_COST_SAVING');
          html_HideItemRow('P21_LOCATION_CODE');
          html_HideItemRow('P21_ACCOUNT_NO');
          html_HideItemRow('P21_SVG_DEPT');
          html_HideItemRow('P21_RATIONALE');
       } else {
          html_ShowItemRow('P21_COST_SAVING'); 
          html_ShowItemRow('P21_LOCATION_CODE');
          html_ShowItemRow('P21_ACCOUNT_NO');
          html_ShowItemRow('P21_SVG_DEPT');
          html_ShowItemRow('P21_RATIONALE');
       }
    }
    I want the items listed to show when the page is loaded when the P21_BEN_SAVINGS is checked (equal to 'YES'), but they are hidden in this situation.

    I see not the onload call in Firebug, and I don't know if it is the configuration of firebug or that JavaScript is not fair.

    Thanks for any help!

    Matt

    Hi Matt

    Try this

    function initialCheck () {
       if ($v('P21_BEN_SAVINGS') != 'YES') {
          $x_HideItemRow('P21_COST_SAVING');
          $x_HideItemRow('P21_LOCATION_CODE');
          $x_HideItemRow('P21_ACCOUNT_NO');
          $x_HideItemRow('P21_SVG_DEPT');
          $x_HideItemRow('P21_RATIONALE');
       } else {
          $x_ShowItemRow('P21_COST_SAVING');
          $x_ShowItemRow('P21_LOCATION_CODE');
          $x_ShowItemRow('P21_ACCOUNT_NO');
          $x_ShowItemRow('P21_SVG_DEPT');
          $x_ShowItemRow('P21_RATIONALE');
       }
    }
    

    Max

    Published by: - Max - April 28, 2010 10:42

    Published by: - Max - April 28, 2010 10:43

  • "Hide / show" regions – how to keep open after send the page

    Hello

    I have several regions ' hide / show ' in my request... when the user submits the page, it closes all the

    is there a way to keep one open that were opened before the page is sent?

    Thanks in advance

    Long answer: forget the hidden item and simply store the values in a cookie.  Use dynamic action, 1 2 plan to store the values when the page is submitted and the 2nd DA to retrieve the value and developing regions.

    Hide and Show parts APEX sticky

    Dynamic action 1

    Name: Save the open areas

    Event: before the Page is sent

    Condition: - no requirement.

    Real Action:

    Action: Run the JavaScript Code

    Fire on Page load: [disabled]

    Code:

    var lOpenRegions = []
    $(".hide:visible").parent(".hide-show-region").each(function()
      { lOpenRegions.push($(this).attr("id")) });
    SetCookie("HideShowOpenRegions",lOpenRegions.join(","));
    

    Dynamic action 2

    Nom : Open saved regions

    Event: Loading the page

    Condition: - unconditionally.

    Real Action:

    Action: Run the JavaScript Code

    Fire on Page load: [disabled]

    Code:

    if (GetCookie("HideShowOpenRegions")) {
      $.each( GetCookie("HideShowOpenRegions").split(','),
                function(intIndex, objValue) {
                  $("#"+$nvl(objValue,"x")+" .hide:first").show();
                }
      );
    }
    
  • LOVs using cascading on the Page elements with values exceeding 4000 characters

    A few days ago, I asked a question on the community, but it turned out that there was something wrong with my account and they have removed the item, so I'll just post the solution I found here now:

    Well, I found a way to use LOVs cascading on page elements with values exceeding 4000 characters:

    Let's say I have a shuttle named P1_ORGANISATIE with "List of values" box, a dynamic LOV named "Source: lists of values Query" containing the value:

    Select NAAM as display_value, ID like return_value

    of NINEHAM

    order by 1

    If the number of records-NINEHAM is insufficient, the length of the value of P1_ORGANISATIE, which is a list of concatenated with colon separated digital ID, can exceed 4000 characters.

    Now, suppose I have a list of selection called P1_TEST that is connected through "List of values"-> "Cascading LOV Parent article (s)" with P1_ORGANISATIE, using a named LOV dynamic with "Source: lists of values Query" containing:

    Select distinct TST. NAAM as display_value, TST.ID as return_value

    of the OTE NINEHAM

    Join the AFDELINGEN ADG ON (ADG. OTE_ID = OTE.ID)

    Join the DEELNEMERS DNR ON (DNR. ADG_ID = ADG.ID)

    Join TESTDEELNEMERS TDR WE (TDR. DNR_ID = DNR.ID)

    Join TESTEN TST ON (TST.ID = RDT. TST_ID)

    where instr (":" |: P1_ORGANISATIE |) '':'', '':'' || OTE.ID | :'') > 0

    order by 1

    In this case, when P1_ORGANISATIE exceeds 3998 characters, you'll get an "ORA-01704: string literal too long"-error and the P1_TEST will show an element called "undefined".

    A way around this is possible because for a named LOV, you can use a "function that returns a sql query" instead of a simple sql query. In other words, we can apply in the context of PL/SQL and thus have maximum for expressions of 32767 instead of 4000 characters. In addition, it is possible to use the two APEX_UTIL. STRING_TO_TABLE and APEX_COLLECTION.

    Setting "Source: lists of query values" on the LOV appointed to P1_TEST with the following code will work:

    DECLARE

    l_selected APEX_APPLICATION_GLOBAL. VC_ARR2;

    l_qry varchar2 (32767): =.

    "Select distinct TST. NAAM as display_value, TST.ID as return_value

    of the OTE NINEHAM

    Join the AFDELINGEN ADG ON (ADG. OTE_ID = OTE.ID)

    Join the DEELNEMERS DNR ON (DNR. ADG_ID = ADG.ID)

    Join TESTDEELNEMERS TDR WE (TDR. DNR_ID = DNR.ID)

    Join TESTEN TST ON (TST.ID = RDT. TST_ID)

    $1

    order by 1';

    BEGIN

    IF: P1_ORGANISATIE IS NULL

    OR LENGTH(:P1_ORGANISATIE) < = 4000

    THEN RETURN

    Replace (l_qry

    ,'$1'

    ,' where instr (":" |: P1_ORGANISATIE |) '':'', '':'' || OTE.ID | :'') > 0'

    );

    ON THE OTHER

    l_selected: = APEX_UTIL. STRING_TO_TABLE(:P1_ORGANISATIE);

    APEX_COLLECTION. CREATE_OR_TRUNCATE_COLLECTION (p_collection_name = > 'ORGANISATIE_COLLECTIE');

    FOR id IN 1.l_selected.count

    LOOP

    APEX_COLLECTION.add_member (p_collection_name = > 'ORGANISATIE_COLLECTIE')

    , p_n001 = > to_number (l_selected (id))

    );

    END LOOP;

    RETURN

    Replace (l_qry

    ,'$1'

    ,'join apex_collections ON APC (APC. COLLECTION_NAME = "ORGANISATIE_COLLECTIE" AND APC. N001 = OTE.ID)"

    );

    END IF;

    END;

    Andreas Groenevelt says:

    A few days ago, I asked a question on the community, but it turned out that there was something wrong with my account and they have removed the item, so I'll just post the solution I found here now:

    Something was wrong with the whole site: AP invoice tolerance

    I don't post anything substantive until we find out what is happening.

  • Page cancel submission using Javascript not dynamic Action

    I build features requiring little Javascript to validate the page before being submitted and prevent sending if there are errors in treatment.  I got this job with the help of dynamic action that fires before Page submit to a condition of firing of Javascript and an action to cancel the event, and it works fine.  However, the intention is to use this feature in several pages and it would be nicer if the functionality could be implemented in Javascript (for example, the code in the page template).

    According to https://api.jquery.com/submit/ this should be possible:

    $( "#wwvFlowForm" ).submit(function( event ) {

      alert( "Handler for .submit() called." );

      event.preventDefault();

    });

    However, I can't make it work in the APEX.  Can anyone suggest a solution?

    during the presentation of the page using apex.submit () (which is probably all cases?), you can use submit it before event like this:

    $(document).on("apexbeforepagesubmit", function(){ alert("before submit"); apex.event.gCancelFlag = true; });
    

    You can find this by looking at the source code:

    page.js

    // Trigger a 'Before Page Submit' event for the document, and pass the current request value for convenience.
    lCancelSubmit = event.trigger( apex.gPageContext$, "apexbeforepagesubmit", lOptions.request );
    // Cancel submission, if the apex.event.trigger function says so (with a true return value).
    if ( !lCancelSubmit ) {
    

    Event.js

    event.trigger = function( pSelector, pEvent, pData ) {
    
          // Default to false, event cancelling should only be done if an event handler says so
          // (by setting this flag to true).
          event.gCancelFlag = false;
    
          // Trigger event
          $( pSelector, apex.gPageContext$ ).trigger( pEvent, pData );
    
          // Return the value of gCancelFlag
          return event.gCancelFlag;
      };
    })( apex.event, apex.jQuery);
    

    Also found in dynamic_actions.js

    /**
     * cancelEvent function
     * Cancels event processing...
     * */
    da.cancelEvent = function() {
    
        /* Set cancel flag in the apex.event namespace to true. This value can be used to cancel subsequent
           processing, such as in page submission to stop the page from being submitted. */
        apex.event.gCancelFlag = true;
    
        /* Set cancel actions flag in apex.event namespace to true. This value is used in dynamic
           actions processing to stop further actions firing. */
        da.gCancelActions = true;
    
        /* Call the event method stopImmediatePropagation. This prevents any event handlers
           bound to the current event from executing. It also calls stopPropagation to stop the
           event from bubbling up the DOM (if it supports bubbling), so any event handlers bound
           to ancestral DOM elements will not fire either. */
        this.browserEvent.stopImmediatePropagation();
    
        /* Call the event method preventDefault. This prevents the default behaviour of the
           event (for example prevents going to the URL of a link, if a link is clicked). */
        this.browserEvent.preventDefault();
    }; // cancelEvent
    

    It could change, but it would be weird. It works, but it is not really written in other than the one in the code documentation.

    Notice also that the event 'submit' is pulled (it would be strange if she didn't)

    //Submit the current form, defaults to "wwv_flow" if not provided in option map
    $( "form[name=" + lOptions.form + "]", apex.gPageContext$ ).trigger( "submit" );
    

    Thus, binding to 'submit' will work, and work, but note that Event.preventDefault () may NOT work depending on the browser used. For me it works in FF, does not check the others. You can try to use "return false;" instead.

Maybe you are looking for