• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

enabling button when text field changes

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a jsp screen in which there are so many text boxes. There is a button at the bottom of the screen. This button will be initially disabled. Once I click on any of the text boxes, the button should be enabled. Can anyone tell me how can I do that without calling a function in the onchange event of every textbox control.
[ December 07, 2007: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could do it on the onclick of the body tag, and then you can set focus to the first text box and then enable the button. The only problem is that if they click on a specific text box you will be taking the focus out of the box that was just clicked on.

Why have the button disabled in the first place if the only criteria to enable it is that they click inside of a text box? That's not really any criteria at all.
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP.

This post has been moved to a more appropriate forum.
 
Lee Sha
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, the user will enter some criteria in one or more of the text boxes and then click on the button which in my case is a "Run Report" button. Once that is clicked, it will be disabled so that the user cannot submit the same report again. The user should be able to submit the report only when he changes the criteria. For that reason, I want to check whether the user clicks on any of the text box even though he does not change the criteria. I am not sure if there is a way to check whether the criteria is changed without adding any complex code.
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bryce Martin:
You could do it on the onclick of the body tag

Huh? Why would he do that?

The event listeners should be placed on the text field that will do the triggering.
[ December 07, 2007: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lee Sha:
I am not sure if there is a way to check whether the criteria is changed without adding any complex code.

Would not an onchange listener be sufficient?
[ December 07, 2007: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please also be sure to take the time to compose descriptive subjects for your posts; read this for more information.

I have adjusted the subject of this post for you.
 
Lee Sha
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If a report takes long time to come back, the user will hit the same report again thinking it is still not submitted. I want to limit that as it creates unnecessary traffic. There are so many text boxes in the screen. Adding event listener for each text box will have so much impact. Is there any other way I can handle this?
[ December 07, 2007: Message edited by: Lee Sha ]
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Doing the following just says they clicked on a textbox, it does not give you any info that they actually added data. Plus it does not work if they use tab to fill in the form.



Now you can have JavaScript add the event handlers



I wrote both of them here untested so they maybe buggy.

Eric
 
Lee Sha
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will try that. Thanks for your help.
 
Bryce Martin
Ranch Hand
Posts: 269
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you have some sort of time constraints? Just add the listeners. If you do it right you will be much happier with the results and they will be much more controlled.
 
Lee Sha
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am confused where to include the above pieces of code. Could you please guide me through this?
 
Lee Sha
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not have any time constraints. This is not the only screen that I have to change. There are some 30 screens. Each screen has nearly 30 to 40 controls. That is the reason why I was trying to control it from one function.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Put it inside of script tags and include it on the page inside the head or body tag.

Eric
 
Lee Sha
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This code is not called at all. I included it in the body within <script> tags. Please advice.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic