What I want to do when user clicks the "Reset selection" button, I want to check the historicalTimeDataOption checkbox. But it doesn't seem to work. The checkbox is unchecked after I press the reset button.
Here's my function:
Thanks in advance for all the help. Don't hesitate to let me know if I can provide with more information.
I think the way you have already coded should work fine as it is, unless some other functionality in your script causing it not to work. There is no difference how you access the radio button using array or id.
You can access a radio object by searching through the elements array of the form, or by using document.getElementById().
I try the two suggestions and they don't work either.
Below is my code:
Joined: Sep 03, 2005
I guess I didn't look at the code keenly before. You were using input type "reset". So according my understanding it resets the page to look like when its loaded. And your onclick function will be executed before it actually does the reset, that means your changes are lost. So either you use input type "button" to get your changes or have the checked="checked" attribute in the input radio for default checked
You would have to use a setTimeout to cause it to happen after the reset fires. Right now you are clicking it, than the reset action happens, which resets it back.
Joined: Jul 05, 2009
I would say just 2 things:
1. edit your function as -
and the call as -
<input type="reset" name="resetBtn" id="resetBtn" value="Reset selection"
onclick="return resetSpeedResultTable(this.form);" />
There is another way to do the same thing, first try this.
2. This all can be done by the power of just "1 word" if you tell : "My requirement is to have that radio button selected by default". Do you want that radio to be selected when the page loads? PLEASE do answer this.
Joined: Oct 13, 2007
Himanshu, thanks. I'll try your suggestion.
Regarding this: "My requirement is to have that radio button selected by default", the answer is no.
Eric, how can I use setTimeout()? can you please explain more?