Javascript onclick event

I've seen what is described below done on an adobe pdf file, and it apparently is javascript, but I am unable to see how it is coded.  I would like to do the same thing on a JSP page.  It would be great if I could add this feature to a java web app that I'm working on.

The adobe pdf file is an online form, where the user can click on a certain area / text field asking for the user's name, and a javascript pop up window will appear, allowing the user to enter his last name, first name, and middle initials.  There are two buttons on the popup window for OK, to insert the information into the blank text field OR cancel to close the popup window.

The name data that is entered gets populated/formatted into the name text filed as Last Name, First Name MI.

I've attached a document showing what I describe, but I'm not sure whether or not the images will be viewable, so that is why I've tried describing the feature as best as I can.

As far as what I've seen in JS tutorials, the onclick is only used for buttons.  Can it work for empty text fields on a jsp as well?  I tried placing the onclick="show_popup()" within a <input  > element, which would be the textbox, but clicking on the text box did not result in the window coming up.
Cy2Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
you may try use onfocus event for <input> element...

http://www.w3schools.com/jsref/event_onfocus.asp
F PCommented:
With jQuery, you can attach a listener on the element and select whatever kind of event handler you want to it at runtime. Here's the documentation and I'll give an example:

https://api.jquery.com/category/events/

<script>
// Once all elements are rendered on the DOM
$( document ).ready(function() {
    // create a variable for the object you want to handle
    var textBox = $('#textBox'),
           orButton = $('#orButton');

    // Then attach the listener to handle the event on that object like this
    textBox.on( "focus", function() {
        // Code wrapped in a function here that listens for the focus to be on that textbox and executes when it does
    });
    orButton.on( "click", function() {
        // Code wrapped in a function here that listens for the click from the mouse to occur when someone clicks the orButton
    });
});
</script>

Open in new window


Make sense?
ironcladsCommented:
You can pop up a form, alert, etc, almost anything when you perform an onFocus() and onBlur() by entering and exiting a field.  When clicking inside a SPAN or DIV, you can perform a onClick() event to do the same thing.

What's probably happening is when entering a field or span/div, a new window pops up with fields.  That popup is most likely a SPAN with fields inside it.  When you click OK in that span, you perform a javascript to populate fields or spans.

I could give you some more information if you are interested.  Let me know.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cy2Author Commented:
Thanks for all the feedback.  Sorry I wasn't able to respond back or award points in a timely fashion as I was pulled away from this issue to something else.  I will need to look at the posted solutions again and see which is the most helpful, though I basically know nothing about jquery and only limited javascript and basic html.   I may post another follow-up question related to this question later.  Meanwhile, I just split the points among all respondents.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.