Access page item from Javascript

I have searched the forum, and based on my findings this is what I've done so far:
I have a page item where the Google Map key is stored. I want to access it from Javascript so that I can call the Google map with the key. (Note: The key can't be hardcoded as it will be pulled from DB according to the environment/url the app is running on. e.g. - dev, test, production.)
Here's a javascript code block:
<script>
   var google_key = $x('P1_GOOGLE_KEY').value;
   var l_url = "http://maps.google.com/maps?file=api&amp;v=2&amp;key=" +
               google_key +
               "&sensor=false";
</script>I have tried, $v('P1_GOOGLE_KEY') , $x('P1_GOOGLE_KEY') , &P1_GOOGLE_KEY. and none of them work.
How do I access a page item from Javascript?
Thx!
Marc

Marc,
I am going to take a shot in the dark, but are you referencing this item outside of a function in your head tag? So basically it tries to reference the item on load? If so this is not going to work because the item does not exist yet. If you are using jQuery change your code to look like:
$(document).ready(function(){
   var google_key = $x('P1_GOOGLE_KEY').value;
   var l_url = "http://maps.google.com/maps?file=api&amp;v=2&amp;key=" +
               google_key +
               "&sensor=false";
});This will tell the javascript to fire after everything has fully loaded. If you are not using jQuery then you can use a little javascript snippet from here to add a ready event to your page. or you can copy paste this into a script tag.
(function () {
  var ie = !!(window.attachEvent && !window.opera);
  var wk = /webkit\/(\d+)/i.test(navigator.userAgent) && (RegExp.$1 < 525);
  var fn = [];
  var run = function () { for (var i = 0; i < fn.length; i++) fn(); };
var d = document;
d.ready = function (f) {
if (!ie && !wk && d.addEventListener)
return d.addEventListener('DOMContentLoaded', f, false);
if (fn.push(f) > 1) return;
if (ie)
(function () {
try { d.documentElement.doScroll('left'); run(); }
catch (err) { setTimeout(arguments.callee, 0); }
else if (wk)
var t = setInterval(function () {
if (/^(loaded|complete)$/.test(d.readyState))
clearInterval(t), run();
}, 0);
document.ready(function (){
var google_key = $x('P1_GOOGLE_KEY').value;
var l_url = "http://maps.google.com/maps?file=api&amp;v=2&amp;key=" +
google_key +
"&sensor=false";
Good Luck,
Tyson Jouglet

Similar Messages

  • How can I access xml document from javascript whithin a JSP page

    how can I access xml document from javascript whithin a JSP page?
    I have a JSP that receives an XML document from a JavaBean, so I can access it within the entire JSP, but I need to access it from the javascript inside the JSP... and I have no idea how i can do this.
    Thanks in advance!

    The solution would only work on MS IE browsers, as other browsers do not support an XML DOM.
    It can be done, but you would be stuck with using the Microsoft broswer. If that is acceptable, I have some example code, and a book recommendation.

  • How To Access PAGE ITEM (single row) from HTML source

    Hi Guys,
    I have a page Item that return a string.
    I would like to show this string
    How To Access PAGE ITEM (single row) from HTML source?
    My desire final output is
    <marquee>:P1_PAGE_ITEM</marquee>
    Can please help me
    Thanks

    Hi,
    You can refer the page items in your page header as &itemname. For example, if I have page item P15_TEST, I will add the following in header:
    <marquee>
       &P15_TEST.
    </marquee>But make sure that you have a process before header to populate the value in your page item. Otherwise, there will be a null scrolling (which you can't see!) :)
    Regards,
    Zahid

  • Set page item from a stored procedure

    Dear reader
    We would like to have a stored procedure to run every 10 minutes. When the procedure starts, the user has to be warned that the update process is running.
    When the procedure is finished, the user should receive a message that the update process is finished.
    What I had in mind was to set a Page 0 item 'P0_REFRESH' and set his value depending on the status of the update. Then add a dynamic action with a change event. So everytime the value of this page item changes, the user will receive a correct message.
    Does anyone know if it is possible to set a page item from a stored procedure?
    Kind regards
    Xnni

    AndyPol
    I found a solution by querying the user_jobs table. In Apex, I created two page 0 items that hold the current status of the job (online, offline) and the old value of the job.
    Online of offline in the current status item is determined by a decode on "this_sec".
    The enext step was to include a html region in P0 that contains some javascript. This javascript will display a message when the values of the new status is different from the old status ;)
    Many thanks for bringing up the ideas.
    Greetz
    Xnni

  • Set application item from javascript?

    Hi!
    Is it possible to set an APPLICATION ITEM from javascript? If so can some one please point me to the thread, or a FAQ or an example, etc?
    Thanks!
    Dave Venus

    dvenus1,
    Sure. In the script below I check variables and populate based on what I find...
    <script language="JavaScript" type="text/javascript">
    function Populate_fld()
    var formVehicle = document.getElementById('P9_HIDE_VEHICLE').value;
    var formState = document.getElementById('P9_HIDE_STATE').value;
    var formTag = document.getElementById('P9_HIDE_TAG').value;
    var formName = document.getElementById('P9_HIDE_NAME').value;
    document.getElementById("P9_VEHICLE").value = formVehicle;
    document.getElementById("P9_TAG").value = formTag;
    document.getElementById("P9_STATE").value = formState;
    document.getElementById("P9_VISITOR_NAME").value = formName;
    if (formState = " ")
    document.getElementById("P9_STATE").value = "FL";
    </script>
    Keep Smiling,
    Bob R

  • Access to Data from Javascript

    I have a propertie call it "country" in my "Data View" and I need access its value from javascript code to use in a IF sentence.
    I try thinks such as "xfa.node.getAttribute("country")" but doens't work.
    How can I access it?
    Thanks.

    You can try like this:-
    if(country.rawValue == "IN")
       xfa.host.messageBox ("You selected India");  // This will display a pop-up
    else
       xfa.host.messageBox ("You selected some other country");
    Chintan

  • Problem with accessing Signed Applet from javascript method

    Hi,
    I am facing the following problem while accessing Signed Applet from javascript method.
    java.security.AccessControlException: access denied (java.io.FilePermission c:/temp.txt read)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at FileTest.testPerm(FileTest.java:19)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at sun.plugin.javascript.invoke.JSInvoke.invoke(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at sun.plugin.javascript.JSClassLoader.invoke(Unknown Source)
         at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)
         at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)
         at sun.plugin.com.DispatchImpl$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at sun.plugin.com.DispatchImpl.invoke(Unknown Source)
    I am using jdk1.5 for my development...
    Can anyone help to resolve this security issue. Urgent...
    Thanks in advance.

    Hey thanks. I wasn't able to get it to work with that sample but I did find this very similar code that does allow javascript to call JFileChooser in an applets public method.
    java.security.AccessController.doPrivileged(
    new java.security.PrivilegedAction()
    public Object run(){                           
    //do your special code here
    return null; //return whatever you want
    It seems a bit tempermental in that if you don't select a file quickly, it will hang the browser....no perfect solution but I'm going in the right direction.
    Thanks,
    Scott

  • Setting page items from Stored Procedure/Package

    Hi,
    Can anyone tell me if it is possible to set the values of page items from stored pl/sql code. I have some reasonably complex biz logic that I want to package and store in the database (not just call an anonymous pl/sql block through a page process). However within that stored code I want to set items on my page based on input parameters, other items on the page or calculations eg.
    I want to do something like:
    :P6_INT_ACC_START_DT := p_bony_auction_dt + 1;
    when trying to compile this code I get invalid bind variable error
    I also tried:
    V('P6_INT_ACC_START_DT') := p_bony_auction_dt + 1;
    but got invalid use of V function error
    Any ideas?
    Thanks, Robert

    Call apex_util.set_session_state:
    apex_util.set_session_state(p_name => 'P6_INT_ACC_START_DT', p_value => p_bony_auction_dt + 1);
    ...although be aware of date-to-varchar2 conversion and use date format masks explicitly.
    Scott

  • Creating page items from pl/sql procedure and using them on a page

    I have a page containing 2 select lists (P21_DEPARTMENTS and P21_DATE). Originally I added them as items that were "select list with submits". The problem is that based on the clearance level of the currently logged on user I only wanted the P21_DEPARTMENTS to be a select list if the user was an administrator. If however the user is not an admin then I want the page to have a hidden form field called P21_DEPARTMENTS that stores the user's department and has a label item that has the department name.
    There is also a report region that generates a table based on the department selected from the select list (if the user is an admin) or the value stored in the hidden form field if the user is not.
    My problem is that I cannot have both those items on the same page and use the HTML built-in authentication to determine which item should be rendered because I need to use the same ID for both items so that the stored procedure in my report region doesn't break. HTML does not permit items to share the same ID.
    I tried to circumvent the problem by creating a stored procedure that performs all of the item rendering in the procedure and uses "htp.p()" to output all of my HTML code. This solution would allow me to pass a parameter into the procedure informing me as to whether or not the user is an administrator. If the user is an administrator the procedure would use a conditional statement and render a select list. If not, the hidden form field and label option would be used instead.
    I finally got the stored procedure working perfectly. Now I am encountering the most bizarre thing. Since the "select list with submit" was not working (I used the same code that gets generated when I created other items using htmlDB's GUI) I decided to use a JavaScript function instead that gets triggered by the onChange event. I send along the value that is currently selected in the select list and in the function I set:
    location.href='http://www.myoraclesite.com/pls/htmldb/f?p=111:21:729740000000000000::NO::P21_DEPARTMENTS:1';
    In theory this should work. The problem is that it doesn't. The page reloads and the P21_DEPARTMENTS select list is not pre-selected.
    The only thing I can think of is that when htmlDB generates page items that you've created with it's own admin tool it assigns some internal guid or something as opposed to when someone tries to generate dynamic page items of their own from a pl/sql procedure it's like the application doesn't even know they exist.
    Any help would be GREATLY appreciated.
    My only other solution would be to create a totally separate page (one for admin and another for non-admin). I would really like to avoid this.
    Thanks in advance.

    I would love to be able to generate my menus and
    various other items in my htmlDB applications in much
    the same way I can using ASP, PHP and Cold Fusion.
    Users should have the ability to write server-side
    code wherever they feel like it. The way htmlDB works
    right now I spend more time trying to figure out how
    to create simple effects and generate simple
    interfaces when I need to be building a portal. Ami - it's important to understand that HTML DB is not like other languages. Thus, trying to force concepts which are common in other languages into HTML DB will often result in more work.
    It's definitely worth the time to go over the HTML DB 2-day Developer, which can be found here: http://www.oracle.com/technology/products/database/htmldb/pdf/B14377_01.pdf
    I can build a portal using Classic ASP, C#, PHP or Cold
    Fusion in like 1/10 of the time that it takes me to
    build one using htmlDB. I understand that this is not
    meant for the hard-core programmer but no web
    programming application in today's day and age should
    prevent experts from getting under the hood.And I can build a Portal in HTML DB in 1/10 the time it will take me to do it in any other language. It's like anything else - proficiency comes with practice and work.
    As for getting under the hood, there is plenty of places you can do that with HTML DB. Keep in mind that HTML DB itself is an HTML DB application, so the limits on what you can build with HTML DB are virtually limitless.
    Sorry for the vent there. After spending the last 2
    days trying to figure out how to implement such a
    straightforward thing and now being informed that it
    can't be done kind of bugged me.I understand your frustration, as I've been there before. My rule for beginners is that if you are writing more than a line or two of code in the first week, you're doing something wrong. Stop, take a break, and then use the ample resources (including searching this forum) to help solve your problem. There are plenty of resources available for you to learn about HTML DB on the HTML DB home page: http://otn.oracle.com/htmldb
    Good luck,
    - Scott -

  • Setting Page Item from Hyperlink

    Hi,
    I am currently developing an APEX application that will show a Google map of our kiosk locations. It builds the javascript in a PL/SQL package using htp.print. For each marker it displays for the kiosk, I'm customizing the info window displayed when the marker is clicked to show the kiosk name, the address and some hyperlinks. One of these hyperlinks will go to another APEX page that displays orders for that kiosk. So, what I'm trying to accomplish is to set a page item value on the page when the hyperlink is clicked that will be used in a page query to pull the orders. I am not much of a javascript programmer, so I'm having some issues. Here is what i'm currently attempting:
    Withiin the FOR loop that builds my markers, I have defined a 'function' as follows:
    htp.print('function setKioskCode (P4_KIOSK_CODE) {');
    htp.print('var kioskcode = '||''''||<location from cursor loop>||''''||';');
    htp.print('$x('||''''||'P4_KIOSK_CODE'||''''||').value = kioskcode;');
    htp.print('}');Then, this is how I'm building the hyperlink in the info window (i've removed the link tags and single quotes so I could post the code). Using this method, I get an error on the load of the map page that says ' Expected ")" '. I can't find any syntax errors in what i have done from what I can tell (I could definitely be wrong!).
    l_order_link := href="f?p='||v('APP_ID')||':6:'||v('SESSION')||'" onclick="javascript:setKioskCode('||''''||'P4_KIOSK_CODE'||''''||');">OrdersWhen I remove the parameter value from the javascript call like this. It loads the map successfully, but, of course, the hyperlink on the marker info window doesn't work.
    l_order_link := href="f?p='||v('APP_ID')||':6:'||v('SESSION')||'" onclick="javascript:setKioskCode();">OrdersAny help would be much appreciated. And please let me know if you need any further info.
    Thanks,
    Troy
    Edited by: tfitz on Oct 21, 2010 1:53 PM

    Thanks for the reply, Jari.
    I have determined you definitely have to use the v('APP_ID') and v('SESSION') in the href statement. Otherwise, it puts the &APP_ID. and &APP_SESSION. in the URL.
    I tried the 'onclick' syntax you provided and it still does not work. I get the error I reported above. It's looking for the closing parenthesis and doesn't like a parameter being provided. If i remove the parameter from the function, the page loads and the hyperlink goes to the proper page but it doesn't populate the page item. I don't know why it doesn't like a parameter for the function.
    Thanks, Troy.

  • Access selectItems component from javaScript

    Hi,
    In the source below I want to access a selectItems component inside of a selectOneRadio from javaScript. I can access the selectOneRadion as in the code below but I can not the selectItems. Anyone who has an idea?
    <afh:script text='
    function showValue() {
    var test=document.getElementById ("form1:radio1").value;
    alert(test);
    />
    <af:selectOneRadio label="Label 1" id="radio1" >
    <f:selectItems value="1" id="radio2" />
    </af:selectOneRadio>
    thanks in advance

    Hi,
    for a select item the code is
    2nd value of a list
    ================================================
    <input type="button" name="click" onClick="alert(document.form1.select.options[1].value)">
    2nd label in a list
    ====================================================
    <input type="button" name="click" onClick="alert(document.form1.select.options[1].text)">
    selected value
    ==========================================
    onClick="alert(document.form1.select.value)"
    where
    <form name="form1" method="post" action="">
      <select name="select" size="1">
        <option value="1" selected>A</option>
        <option value="2">B</option>
        <option value="3">C</option>
      </select>
      <input type="button" name="click" onClick="alert(document.form1.select.value)">
    </form>
    Frank

  • Example of setting page item using javascript

    Does anyone have an example of setting the value of a page item (hidden) using javascript? I have seen the following in the Forum but I am having trouble implementing it. If someone could show an example of a region it is called from, and the javascript (and where it is placed), that would be great.
    I have tried something similar to this without luck so far:
    function setValue(){
    $x('P1_FIELD').value = 'Oracle';
    Thanks!
    John

    Hi VS,
    you should really use a "Set Value" dynamic action for that, that's much more transparent than using the onclick definition in the button attributes.
    Regards
    Patrick
    Member of the APEX development team
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • Accessing page items in the document but outside the page bounds

    I'm as new to indesign as I am to indesign scripting so bear with me and my lack of termonology. I have page items that are in the whitespace that is in the document but outside the page bounds. I have access to all the page items that are even partially on the page using the myPage.pageItems. However this collection doesn't include those page items that aren't touching that page. So is there anyway to access those page items in the whitespace outside the page?

    OK, so where are you stuck?
    If you have a variable, say, page, that is a particular page, where page.pageItems is all the items on that page, then page.parent.pageItems will be all the items on the spread, which includes the pasteboard surrounding it.
    Good?

  • Access page fragment from a page or vice versa

    How can you access (get and set) the components of page fragment from a page?
    I have a page fragment with a drop down box, which is shared across many pages. Now the value of the drop down list (in the page fragment) needs to changed based on the table columns of the page. I can easily do that if the drop down is on the same page as the table component, but I can't figure out how to do this if drop down is on a page fragment and the table is on a page. In other words, how do we make the page "see" its page fragment programmatically or vice versa? When you use this.xxxx, you only get access to page components and it does not include the comonents of the page fragmant which is embedded in the page.
    Thanks
    Message was edited by:
    Sabir

    What happens if a user were to have multiple browser windows open under the same session?
    Let's say I had a header like this example and I disabled some of the links on given pages. If a user had 2 pages open, and both has an instance of this header page fragment being rendered, which page's header would have its link disabled? Would it be both or would it somehow know to only affect the fragment within the page that's calling .disabled(true)?

  • Accessing java classes from javascript

    Hi,
    I have the following javascript function
    function testjava {   
        var myString = new java.lang.String("Hello world"); // line 1
        alert("len:"+myString.length()); // line 2
    }It gives me a error at line 1 saying "'java' is undefined" in IE browser 5.5 sp2. But, both the lines execute correctly in netscape 6.
    Can someone please help..
    Thanks,
    Vijay.

    It seems that IE 5.5 doesn't support accessing java classes in JavaScript, so try to install IE 6 to see if it works or maybe, you doesn't have installed propertly support for JVM in IE.

Maybe you are looking for

  • Intune & Third Party Software Automatic Updates

    Can Windows Intune ensure third party software such as Java, Adobe Reader, & Flash is updated? I at-least want an email when a PC has an out of date version of the above software. If Windows Intune can't do this, any recommendations? We're a small bu

  • Starting and Stopping the Portal

    Hi all    After deploying my PAR, I am restarting the whole <b>SAP Instance</b> in the Server. 1. Is this the right way ??? 2. Is there any other easy way to restart/stop the PORTAL alone instead of touching the SAP Instance??? Thanks Kay

  • Changing modifier keys on only  external keyboad

    There was a similar post that was labelled as solved, but in fact did not address the greater problem. I have the same problem as the original poster in this thread: http://discussions.apple.com/thread.jspa?threadID=778597&tstart=0 but the solution p

  • Creating PDF documents

    I realize this may not be the place to post this but I don't know where else to turn on the Apple forum. I was to be able to combine PDF documents or add pages. Is there any Apple software that enables me to accomplish this? I have Adobe Acrobat on t

  • Duplicates of Songs?

    I know I can find and delete duplicates, but the duplicates only show on my Ipod touch. Not on itunes. In my Music Libary on ITUNES, there are NO duplicates. But when I am listening to music on my IPOD, it shows a duplicate of EVERY song. WHy is this