This discussion is archived
2 Replies Latest reply: Jan 16, 2013 5:49 AM by 635396 RSS

Javascript alert

635396 Newbie
Currently Being Moderated
Hello,

I'm trying to get a javascript alert to pop up when the user enters a person's name that already exists in the persons table.

I wrote a plsql function that returns the names of people already in the table (names that match the name the user entered) and I need to get the result of this function in a javascript alert.

I don't want to use validations because I'd like the alert to appear immediately after the user updated the name field.

I also want the message to be just a notification for the user and let the user decide if he wants to insert the same person multiple times.
I tried to do this with dynamic action that executes plsql code but with no success.

Any ideas on how to do this?

Thanks, Adrian
  • 1. Re: Javascript alert
    KeithMalay Explorer
    Currently Being Moderated
    Hi Adrian,

    You could accomplish this by calling a javascript function "on-change" of the text field. The javascript function would need to *1.*Get the existing usernames from an on-demand process, *2.*Check the user-entered name against the results of the on-demand process, *3.*Present a javascript dialogue box to confirm the action.

    With that being said, I would consider using built-in APEX functionality to simplify, such as Text Field with Autocomplete. Instead of the normal text field you're using now, you could switch it to type Text Field with Autocomplete and specify an LOV query, such as:

    select user_name
    from your_user_table
    order by 1

    As the user types, they can see a list of names that already match what they're typing. In my opinion, this would be a much more elegant way to solve the problem.

    Not to mention much less work, which we're all fans of :)

    Here's an example of the Text Field with Autocomplete in case you haven't used it.

    http://apex.bhawke.com/apex/f?p=104:7
    user = demo
    pass = demo

    Hope this helps.

    Keith Malay
  • 2. Re: Javascript alert
    635396 Newbie
    Currently Being Moderated
    Hello Keith,

    I'll use the elegant and easy approach :)

    Thanks

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points