Retrieve city and state from zip code that is entered by user

I am trying to use AJAX to retrieve city and state from a table based on a zip code that is entered by the user. Two are text fields (zip code and city) and one is a SELECT field (state).
1. I defined an application item called TEMPORARY_APPLICATION_ITEM.
2. I defined an application process called SET_CITY_STATE as follows:
    a. Process point: on demand
    b. type: anonymous block
    c. process text:
<pre>
DECLARE
v_city VARCHAR2 (100);
v_state VARCHAR2 (2);
CURSOR cur_c
IS
SELECT city, state
FROM ZIP
WHERE zip = v ('TEMPORARY_APPLICATION_ITEM');
BEGIN
FOR c IN cur_c
LOOP
v_city := c.city;
v_state := c.state;
END LOOP;
apex_util.set_session_state('P2_CO_CITY',v_city);
apex_util.set_session_state('P2_CO_STATE',v_state);
EXCEPTION
WHEN OTHERS
THEN
apex_util.set_session_state('P2_CITY','Unknown city');
apex_util.set_session_state('P2_STATE',null);
END;
</pre>
3. Javascript is defined in the region header:
<pre>
<script language="JavaScript" type="text/javascript">
<!--
function pull_city_state(pValue){
var get = new htmldb_Get(null,html_GetElement('pFlowId').value,
'APPLICATION_PROCESS=Set_City_State',0);
if(pValue){
get.add('TEMPORARY_APPLICATION_ITEM',pValue)
}else{
get.add('TEMPORARY_APPLICATION_ITEM','null')
gReturn = get.get('XML');
get = null;
//-->
</script>
</pre>
4. In the HTML Form Element Attributes of the P2_CO_ZIP text item: onchange="pull_city_state(this.value)";
The city and state are not being populated. I checked the select statement and it is retreiving the city and state in SQL WORKSHOP > SQL COMMANDS.
I would like to use it for the mailing address as well, so I would need to make the application process / javascript a bit more generic to be used in two places.
I placed the application on apex.oracle.com:
Workspace: RGWORK
Application: Online Certification Application (28022)
Can someone assists, please.
Thank you,
Robert
Edited by: sect55 on Jun 2, 2009 4:11 PM

Hi Robert,
Try using XML instead of session state -
Change the application on demand process with the following script -
>
DECLARE
v_city VARCHAR2 (100);
v_state VARCHAR2 (2);
CURSOR cur_c
IS
SELECT city, state
FROM ZIP
WHERE zip = v ('TEMPORARY_APPLICATION_ITEM');
BEGIN
FOR c IN cur_c
LOOP
v_city := c.city;
v_state := c.state;
END LOOP;
OWA_UTIL.mime_header ('text/xml', FALSE);
HTP.p ('Cache-Control: no-cache');
HTP.p ('Pragma: no-cache');
OWA_UTIL.http_header_close;
HTP.prn ('<body>');
HTP.prn ('<desc>this xml genericly sets multiple items</desc>');
HTP.prn ('<item id="P2_CO_CITY">' || v_city || '</item>');
HTP.prn ('<item id="P2_CO_STATE">' || v_state || '</item>');
HTP.prn ('</body>');
EXCEPTION
WHEN OTHERS
THEN
OWA_UTIL.mime_header ('text/xml', FALSE);
HTP.p ('Cache-Control: no-cache');
HTP.p ('Pragma: no-cache');
OWA_UTIL.http_header_close;
HTP.prn ('<body>');
HTP.prn ('<desc>this xml genericly sets multiple items</desc>');
HTP.prn ('<item id="P2_CITY">' || 'Unknown city' || '</item>');
HTP.prn ('<item id="P2_STATE">' || '' || '</item>');
HTP.prn ('</body>');
END;
>
in your javascript make sure you typing the application process name correctly as it is case sensitive.
Hope this helps,
Regards,
M Tajuddin
web: http://tajuddin.whitepagesbd.com

Similar Messages

  • Retrieving images and numbers from broken iphone that was not backed up

    My Iphone 4 will only go to the part where the white apple appears, and not roll over to the main menu.  I can however make phone calls with it still using my bluetooth in my car only.  I have never backed up my Iphone before (yes I know that was dumb)  BUT is there anyway to retrieve information from the phone at all?

    Thanks!

  • Auto-populate city and state based on zip code?

    Based on the zip code entered, can the form auto-populate the city and state in another field?

    Formscentral doesn't support this type of relational type of functionality.
    Andrew

  • I'm trying to create an address spread sheet for my wedding invites and won't let me type zip codes that start w a zero "02904" it just automatically drops it "2904" how do u fix that?

    I'm trying to create an address spread sheet for my wedding invites and won't let me type zip codes that start w a zero "02904" it just automatically drops it "2904" how do u fix that?

    The easiest fix is to format the receiving column as Text prior to making your entries.
    Another way is to format as "Numeral System", Base: 10, Places: 5. This doesn't work so well if you need the 4 extra digits that some people like to use.
    It's also possible to create a Custom Format, but it's rather more involved.
    Regards,
    Jerry

  • Is there a way to search by Street Address, City and State Proximity?

    I want to search by only street, city and state proximity, not Zip code/postal code and distance by. Something like this image. How can I search a web app proximity only by a person's street address?

    Theodore Becker wrote:
    As far as I can tell you can no longer search your devices library , only your past iTunes purchases
    Works fine here.
    Select your device in iTunes and search away.
    I have no problem with the cloud , but I have a problem with
    Taking away from the iPod function I used to have
    Then you have no problem.
    As a work around , ( a very timely and tiresome work around ) I simply create
    A playlist with all the songs I have on my device
    Actually, that is a much, much easier solution to select what you want on your iDevice.
    Sycn selected playlists and select this (and other) playlists as you want.
    Don't need iPhone plugged in or connected to add/remove from playlist. Change it whenever you want then simply sync yrou iphone.
    You can use smart playlists to help find what is not on iPhone (Playlist is not my iPhone playlist).

  • Vendor Master - street addr and PO box/different city and state

    Issue:  Check print for vendor is wrong when both street and PO Box address are populated in Vendor Master.  Print Preview shows correct PO Box with correct city and state, but when check prints using the PO Box, it uses the city from the street address.  Please help.
    Example:
    Street address for vendor is Westport, CN.
    PO Box for vendor is Newark, NJ.
    Edited by: Jan Ackerman on Sep 17, 2008 10:48 PM  Meant to type CT, not CN.

    If we change the Print Program to use the PO Box, will the SAP Print Program still know to use the street address for vendors that don't have a PO Box?  Please confirm. Thank you!

  • How to isolate the Sql Statement from Java Code

    Hi
    I Need to know that can we segregate the Sql Statements and convert them to Stored Procedures so as to isolate the Sql statements from Java Code.
    So i have one static web page which uses four select Statements so what i want is to create a stored procedure encapsulating these queries. So that the Java Web Developer will simply call the Stored Procedure instead of using four different SQL Statements.
    Suppose the developer has these four Statements
    Select ename,empno,sal,job from emp;
    select empno,ename,mgr from emp;
    select deptno,dname from dept;
    select emp.ename,emp.empno,emp.deptno,dept,dname fromemp,dept;
    So can i encapsulate these four Sql Statements in one Procedure and the Web developer can call the Store procedure and dont need to write the Sql Statements in his code.
    Can Anybody guide me how to write this Stored type of Store procedure.
    Thanks

    http://www.google.com/search?q=java+windows+registry
    Next time, search yourself. It might be beyond your belief, but you're really, really not the first person to wonder about this.

  • How to get the name of the city and state of the current location of the user

    Hi all
             i need to get the name of the city and state (full address) of the current location of the user.
    need help.

    The best way to do this is to put the monitor name as a property bag in the script and pass that to your event details. Otherwise, we're looking at querying the database each time the monitor generates an event, and this is overhead that is really not
    necessary. The other option, which is just even worse in terms of performance, is to use powershell to query the SDK for the monitor name. Both of these options are not going to be a good solution, because now you need to implement action accounts that can
    either query the database or the sdk.
    Jonathan Almquist | SCOMskills, LLC (http://scomskills.com)

  • How to retrieve a prepared statement from prepared statement cache?

    Hi All,
    I have created the connection pool during application server startup. The connection pool are getting created successfully. I have also created the prepared statements and stored as part of each connection in the connection pool.
    can anyone please tell me on how do I retrieve a prepared statement from prepared statement cache from a connection object.
    Any pointers to info source will be REALLY appreciated.
    Many Thanks in Advance,
    C R Baradwaj

    Raghuram Bharatwaj C wrote:
    Hi Joe,
    I have created a connection poool in my startup class and created the
    neccessary prepared statements for a each connection. I have 10 prepared
    statements to be created for each connection. I have created all the 10 prepared statements using the loop as mentioned below
    String [] epc_stmts;
    private java.sql.PreparedStatement[] _pstmts;
    if (epc_stmts!= null)
                   _pstmts = new PreparedStatement [len = epc_stmts.length];
                   for (i=0; i<len; i++)
                        _pstmts[i] = db.prepareStatement (epcstmts);
    I have closed the connection after the prepared statements are created.
    Now, How do i access a prepared statement from the connection object.
    Nothing. Are you talking about a WebLogic pool? If so, then therafter,
    whenever your application gets a pool connection, when it calls
    prepareStatement() with the same SQL as you prepared those statements,
    it will get a cached statement. Your array is unnecessary.
    Joe
    >
    Many Thanks in Advance,
    C R Baradwaj

  • HT1937 Hi I'm Ronald Macatangay. I use IPad to, my problem is I forget the code that I enter in a restriction and I can't delete some of my apps. Can you halp me. Thanks

    Hi I'm Ronald Macatangay, I using iPad2 and I'm having a problem with restrictions I forgot the code that I enter. And I can't delete some of my apps. Can you help me? Thanks

    You will need to connect it to the computer you sync with and Restore it as a new device then rebuild everything manually. If you restore from your backup it will restore the restrictions password.

  • I am trying to reboot my granddaughters I pod it gets to 22 minutes the iPod switches on automatically and requests her pass code that she has forgotten please advise

    I am trying to reboot my granddaughters I pod it gets to 22 minutes the iPod switches on automatically and requests her pass code that she has forgotten please advise

    Forgotten Screen-Lock Passcode
    Connect the iOS device to your computer and try to make a backup
    iOS: How to back up
    Then restore via iTunes. The iOS device will be erased. Place the iOS device in Recovery Mode if necessary to allow the restore.
    If recovery mode does not work try DFU mode.
    How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
    For how to restore:
    iTunes: Restoring iOS software
    To restore from backup see:         
    iOS: Back up and restore your iOS device with iCloud or iTunes
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload most iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store   
    If problem what happens or does not happen and when in the instructions? When you successfully get the iPod in recovery mode and connect to computer iTunes should say it found an iPod in recovery mode.

  • Music store account city and state are perpetually "null" -asks for update

    I am trying to buy something through the music store. All my information is there, but it keeps prompting me to update my billing information. My city and state are blank, so I type them in and hit 'done' and it asks me for my county information, which I update.
    Then it returns me to the music store where I hit "buy song" again. Then I am prompted to log in and update my billing information all over again.

    You can't.  Apps are forever tied to the AppleID that purchased them.  Delete the apps with the old AppleID and purchase them with the new AppleID.

  • Delivery with UPS?? ship to only having city and state?

    on the ship to area in the tracking area of the UPS tracking system, it only says the city and state, no other address information. is that common?

    Hi,
    Thank you upnorth for your input. Adding to what was said, the ship to area on the UPS tracking system would only give the city and state as to protect the privacy of the sending and receiving of an item.  However, the created tracking number should only give the shipper and receiver the complete information on tracking any item. Please refer to this link for more information.
    http://www.ups.com/?Site=Corporate&cookie=us_en_home&setCookie=yes
    Thanks, 
    [email protected]

  • HT201493 When I add a person in io6 their email is only displayed not their name and picture from my contacts that the email is associated with, why?

    When I add a person in io6 their email is only displayed not their name and picture from my contacts that the email is associated with, why?

    The whole idea to an icloud account is that one user uses it and has all their devices synced together.  Different users need different Apple IDs to create their own icloud accounts.  Note that everyone can still use the same ID for an iTunes account (to share purchases).
    To create a new icloud account, go to
    http://www.apple.com/icloud/setup/

  • My Itunes account was hacked and my Apple ID was disabled. I followed the instructions from APPLE to backup and restore from Itunes but that did not work. Any suggestions?? Thanks!!

    My Itunes account was hacked and my Apple ID was disabled. I followed the instructions from APPLE to backup and restore from Itunes but that did not work. Any suggestions?? Thanks!!

    Are you saying that you contacted Apple support and they instructed you to backup and restore your iPad? Or do you mean that you picked up this information from an online support article? If you spoke to an Apple rep or received these instructions via email, contact them again for further help.
    I fail to see how restoring your iPad would enable yoyr Apple ID.

Maybe you are looking for