This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Change value in form onClick Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Change value in form onClick" Watch "Change value in form onClick" New topic
Author

Change value in form onClick

Jill Snider
Greenhorn

Joined: Nov 27, 2009
Posts: 6
Hi all,

I have radio buttons to select 'ALL' or a 'Custom' date in a JSP web application.
Custom date works great and so does ALL.
However, if the user changes their mind and goes from Custom to ALL, the dates remain.
I’m already using an onClick Javascript to hide/unhide the custom fields that show up to enter a dates in a text input field when ALL is selected.





I would like to be able to reset the date field if the user selects all by including a command in the onClick Javascript.


I’ve tried everything I can think of! Any help would be appreciated.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
allSelected !== AllSelected
Jill Snider
Greenhorn

Joined: Nov 27, 2009
Posts: 6
Hi Eric,

Thank you so much for the reply.
However, it didn't work.

When I toggle back betwen Custom and ALL it still shows and carries the values over to the next page.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
well do you have an error message in the console?

Eric
Jill Snider
Greenhorn

Joined: Nov 27, 2009
Posts: 6
No error message at all upon compile or running in the browser.
It just has the old values from custom when I select ALL again and when I go to the next page in a form.
Ultimately, I would like to reset the values not only when selecting the ALL radio button but also when using the Back Button.
Arg!

Thanks for your help!
Justin Fox
Ranch Hand

Joined: Jan 24, 2006
Posts: 802
Jill Snider wrote:Hi all,



I think your function call names need to be the same, for example in the onclick you have 'allSelected', but your function is defined as 'Allselected()'.

Also, I've never used visibility so it could work, but I've always used ...style.display = "none";

I'm surprised it didn't give you an 'object expected' error. But if you're using ff it will just not work, won't give you errors like IE.

Justin


You down with OOP? Yeah you know me!
Jill Snider
Greenhorn

Joined: Nov 27, 2009
Posts: 6
Hi there,
Thank you all for your help.
I figured this out and wanted to post what ended up working for me in case anyone else had the same issue.

The HTML:



The javascript for the functions 'toggle()' and 'allSelected()'

toggle()



allSelected()


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Change value in form onClick