Forum Stats

  • 3,851,566 Users
  • 2,263,999 Discussions
  • 7,904,781 Comments

Discussions

Auto-populate form based on input field

Jules123
Jules123 Member Posts: 18
edited Jul 3, 2014 11:12AM in APEX Discussions

Hey everyone,

I have a form on the EMP table, with an input field containing the empno.

When I enter a (valid) empno, I'd like to fill all the information (ename, job, ...) automatically in the fields.

I read somewhere that I just have to write a query for every input field + a dynamic action that refreshes the whole region with the form when I change the value in empno.

Now is it possible to skip the query writing, and only use the ARF process?

Thanks in advance,

Jules

Tagged:

Best Answer

  • Jaydarp-Oracle
    Jaydarp-Oracle Member Posts: 44
    Answer ✓

    If you do not want it to resubmit... You can use DA, that executes PL/SQL code, with code like  "select yyyy into : PXX_ITEM"  for instance...

    To trigger this DA, you can either way set it up through the DA, or you could set it to be "CUSTOM" event, and by pressing that fetch, make it execute a jscript that would do a $.event.trigger("Custom_name"); 

    That should do it to avoid the submission... if that is what you want.

«1

Answers

  • Danny*D
    Danny*D Member Posts: 114 Bronze Badge

    make the page work with the automatic row fetch first

    set the Submit when Enter pressed = yes for Pxx_EMPNO

    if you enter a valid empno and press enter, page will fetch the record.

    if you enter a invalid empno and press enter, 'No data found' error, better validate the EMPNO in a validation after submit.

  • Jules123
    Jules123 Member Posts: 18

    Hi Danny,

    thanks for your answer!

    But what I want to do is to automatically refresh a form as soon as I enter a valid empno (maybe with autocomplete included), WITHOUT hitting enter.

  • Danny*D
    Danny*D Member Posts: 114 Bronze Badge

    how to you define 'refresh a form as soon as I enter a valid empno'? when you tab out or click out of the field?

    if yes, add dynamic action to Pxx_EMPNO on change submit page

    otherwise, if you want the page to refresh as you type, use dynamic action/ajax to validate the input against DB records onkeypress, if exists, submit page

  • Jules123
    Jules123 Member Posts: 18

    But submitting means that the page must be reloaded again?

    So it's like clicking on enter?

    I think it was in a form in MS Access where you just entered last and first name, and as soon as you clicked out of the field, it auto-filled the rest of the field.

    Guess it's not possible?

  • Jaydarp-Oracle
    Jaydarp-Oracle Member Posts: 44
    Answer ✓

    If you do not want it to resubmit... You can use DA, that executes PL/SQL code, with code like  "select yyyy into : PXX_ITEM"  for instance...

    To trigger this DA, you can either way set it up through the DA, or you could set it to be "CUSTOM" event, and by pressing that fetch, make it execute a jscript that would do a $.event.trigger("Custom_name"); 

    That should do it to avoid the submission... if that is what you want.

  • Jules123
    Jules123 Member Posts: 18

    Hey, nice idea!

    I'd trigger it through the DA I think.

    But does the PL/SQL code / the SELECT INTO query really fill in the empty form fields - without submitting the page again?

    Because I thought that this PL/SQL command only inserts the needed values into session variables and that after a page submit/reload, the items are filled with the session variables?

  • Jaydarp-Oracle
    Jaydarp-Oracle Member Posts: 44
    edited Jun 7, 2014 11:51AM

    You will have to put a full block:

    declare

      --variables if any

    begin

    end;

    But that should do the trick.

    DA does submit your code, but not in the reload way you think

    DA can communicate with your DB without refreshing the page, but items do get submited, in the pl/sql code option, it asks you to submit the items you will be using inside your code... you just simply enumerate them... the DA does the rest.

    Think of DA as AJAX code... to get the idea.

  • ebenwalker
    ebenwalker Member Posts: 178
    edited Jun 7, 2014 1:43PM

    can you start at the begining.... how do I make a form do "automatic row fetch"  -- where do I get that process?

    UPDATE:  found out how to make an Automatic Row Fetch Process

    -  still haven't figured out how to trigger it.

    created a dynamic action to submit page on change but page does not fill in with fetched data?

  • Jules123
    Jules123 Member Posts: 18

    Thanks jaydarp!

    I found some time today to test it - and it works like a charm

    But one last question: If I use this dynamic action (which can also be fired at page load), do I still need a supplementary Automatic Row Fetch Process?

    It would have been great to trigger the ARF process at page load + when I change the primary key item value (= no PL/SQL code writing necessary), but it's unnecessary to use ARF + custom code?

  • ebenwalker
    ebenwalker Member Posts: 178

    I am attempting to replicate this approach

    I tirgger with a mouse click

    I can see the pinwheel of the dynamic action running but nothing displays

    PL/sql is

    begin

    select  ename, job into

    :p16_ename,

    :p16_job

    from emp e

    where :p16_empno = e.empno;

    end;

    Frustrating?

This discussion has been closed.