Link to home
Start Free TrialLog in
Avatar of circle1d
circle1d

asked on

Javascript - How can I trigger a button click when a text field has data inputed to it?

This should be pretty simple, I just can't get it. I need a ClickMe command of some type to automatically press a button that is being manually pressed now. The user fields in his name and then presses a button to populate the email, address and phone number fields, I need that button press to be transparent of the user.
Avatar of Bill-Hanson
Bill-Hanson
Flag of United States of America image

Yep, this is an easy one.  Just call the button's click method:

document.formId.buttonId.click();
Avatar of circle1d
circle1d

ASKER

The text field is named "CallerName", when the field is focused or changed on exited, I need th e"go" button to be pressed. I hate being such a novice, but please provide the code and the placement thereof to get this to function properly so that th euser does not have to press it, nor even see the button
ASKER CERTIFIED SOLUTION
Avatar of Bill-Hanson
Bill-Hanson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
What I am doing is utilizing a Domino Name Picker, located here... http://www.codestore.net/store.nsf/unid/FISR-6MPRGU to pick a caller's name from a names.nsf drop down list, once the name has been inputed into the callername field, I click the "go" button to run a DBLOOKUP on that name to populate 3 other fields, email, phone and company. Of course the domino name picker is far to complex for me to figure out what I need to do in order to get the script to populate all the fields without having to run a separate DBLookup for them. I will be accepting your answer tomorrow, but I am giving you the opportunity to look at the code to see if you would like to tackle my issue from the name picker standpoint and if so I will tack on an additional 375 points. Thanks
Small world!  I'm a certified Domino developer AND I've implemented a similar name picker in my own web apps.

There are a couple of things that you can do to make your app much cleaner, but I don't have time to explain right now.

One method involves calling a function from the popup instead of setting a field value.

The other method involves calling @DbLookup from JavaScript via AJAX.

Neither technique is very complicated, and will eliminate the button-click workaround.

I gave you a B because you said you had more to offer, but didn't have time to share it, so an A would not be appropriate, thanks.
I really don't care about the points that much, but this time, you struck a nerve!

You should not have reduced the grade since the original question (How can I trigger a button click?) was answered clearly and correctly.

I WAS going to assist you with the Domino-specific aspects so that your picker control would really shine.  Now I just don't feel like it.
I have no qualms about your not being able to assist me further, I appreciate your assistance. This is my first time awarding points and only lowered the grade because you said you could have done more. There was no intent to offend and I hope that this experience will not cause you to pass by my name if you should see a question from me in the future. Thanks.
No problem, you probably never read the grading guidelines:

"An answer is worth an A, unless it doesn't resolve your issue. If it requires you to do a little more research, or figure out one more piece of code, then it's worth a B. If you think it's not worth a B, the custom is to offer the Experts an opportunity to earn a better grade."