Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 4th, 2004, 07:42 PM
Authorized User
 
Join Date: Jun 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default control groupings (radio buttons and check boxes)

Hi:




I have a group of controls, specifically checkboxes, all with the same name but different values.

My goal is a simple 'undo' to erase ill-effects of accidentally clicking the wrong checkbox.

When one specific checkbox (value = 'NA') is checked, I want to gather the values of all the other checkboxes in the same group and store them in a hidden textbox, then clear the all the other checkboxes.

If any other checkbox in that group, other than 'NA', is checked next, I'll replace the stored values in the textbox with an empty string.

If 'NA' is cleared, I want to restore the settings stored in the textbox.

Again, the goal is a simple undo. Check 'NA' and the values are stored and cleared. Immediately uncheck it, and the stored values are restored. Check any other checkbox after 'NA' and no undo is possible.

I don't really have a problem accomplishing this task, but I'm not sure I'm doing it as well as I can.

So, at long last, my real question:

Does this task require looping through the array of checkboxes twice? Once to determine the '.checked' state of the 'NA' checkbox and a second time to then capture/restore the values as appropriate?

Because all of the checkboxes have the same name, that is the only way I can come up with to do this task.

Am I overlooking something?

Thanks for your time.

JK
 
Old April 4th, 2004, 11:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

Hi there, if I got u correct, & u wanna make an undo in ur form put a button in the form & set the type as RESET, as follow:
Code:
<input type="reset" value="Reset">
REMEMBER: its woeks only into <form> tag.
HTH.

Always:),
Hovik Melkomian.
 
Old April 5th, 2004, 12:36 AM
Authorized User
 
Join Date: Jun 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Hovik:

Thanks for the help, but I don't want to reset the entire form.

The application is a survey. One of the questions is such that you can check one or more of the checkboxes. But one of the choices states that this question does not apply to me. So, if one checks this box, then all the other boxes must be cleared to maintain a consistent answer. However, it is possible to accidentally check that box. In that case, if you immediately go back and uncheck it, I want to restore all the checkboxes for this question to the same state they were in prior to the accidental checking.

JK
 
Old April 5th, 2004, 02:40 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

SO first u need to store the defual vales & when u want release them. I did it once like this
make a function to read them onload() as
FORM1.CheckBox1.realIndex = FORM1.CheckBox.checked;
Then when u need to reastore them do as
FORM1.CheckBox1.checked = getdeputyinfo.elements.realIndex;

u dont need for any hidden textbox or anything else in this solution.
HTH.

Always:),
Hovik Melkomian.
 
Old April 5th, 2004, 11:00 AM
Authorized User
 
Join Date: Jun 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Hovik:

I don't understand the proposed solution, so I don't know if this answers my question or not.

What is the 'getdeputyinfo' object, and the 'realIndex' property? I haven't been able to find any reference to them. I'm not looking for a full definition, just to be pointed in the right direction.

Keep in mind that I'm not talking about default values. Because this is a survey, there are no default values. The person completing the survey must answer each question. If default values were in place and they overlooked one or more questions, the data would not be a complete and proper representation of their responses. I am looking to restore values that the person set

JK
 
Old April 5th, 2004, 11:43 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

first of all excuse me for [u]getdeputyinfo</u> its only a form_name of mine page & I submited u by mistake
Anyway, as I get:
u have a form that after load or anything u wanna have ur values to undo them to last fixed values.
if its so, all I said was for that. & about realIndex its a dumy property to store values, instead of useing Hidden_textbox & ...

I'll be glad if I could help u, keep in touch if u have problem again.
HTH.

Always:),
Hovik Melkomian.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create Check Boxes/Option buttons/Option Group hewstone999 Access VBA 1 March 14th, 2008 07:25 AM
InfoPath radio buttons MichaelBjerke Infopath 0 May 29th, 2007 10:27 AM
Radio buttons disappear JoeBob49 ASP.NET 2.0 Basics 2 November 27th, 2006 09:57 AM
How to use the radio buttons? ben_VB VB.NET 2002/2003 Basics 1 January 18th, 2005 12:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.