LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 07-28-2007, 04:51 AM   #1
rblampain
Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 7
Posts: 790

Rep: Reputation: 32
javascript validation of ordered list


Casual Javascript user - not a learner.
I have a complex html form that needs javascript validation and I cannot figure out how to do that although I think it is probably not as difficult as I think.

I thought the best way to show my problem is to cut and paste the result of the html. This HTML is created by a BASIC program with a sample text file as an input and it has been validated by the W3C validator although the cut and paste destroys the numbering created by the tags <ol type="?"> where "?" can be any valid type (A, I, a, i, 1), these have been reconstructed by hand.

Also, to keep the correct indentation of the ordered list, I have sustituted spaces with underscores.

We can compare the ordered list of this html as a recursive directory of files.

This form consists of a number of elements each giving 3 choices from radio buttons that have the name and values set as shown in each line below ( name="Policy" value="Policy", name="Section 1" value="Section 1", etc).

As it is, the script allows clicking one of three radio button for each element, which is not what is intended.

The problem to be solved with javascript is that on each "onChange" (or onClick) all the invalid boxes checked must be unchecked. These invalid boxes are all the radio boxes leading back to "Policy" from the target radio box plus all the radio boxes below it, including all the forks below.

There is no need to test if they are checked or not, just uncheck them. Each individual line should only have one radio box checked.

The idea is that if you click any particular radio box, the same vote is given for everything this "container" holds.

For example, if the user clicks one of the radio buttons associated with "Subdivision 2.", everything clicked from "Policy." to "Division 2" should be unchecked and everything clicked from what follows, "Category 1" or "Category 2" and below should be unchecked because what is below "inherits" the same vote although what is done from "Subdivision 1." or "Subdivision 3." and below does not affect this instance of validation because they belong to a different "fork" or line.

I hope my explanation makes sense to you.

Any tip most welcome, I have searched on the net but found nothing related to this sort of scripting even though I think it must be fairly common.

Thank you for your help.

Here is the rendering of the html.

Vote Yes on Policy
Vote No on Policy
Abstain to vote on Policy

A. Vote Yes on Section 1.
__Vote No on Section 1.
__Abstain to vote on Section 1.
___I._Vote Yes on Subsection 1.
_____Vote No on Subsection 1.
_____Abstain to vote on Subsection 1.
______a Vote Yes on Division 1.
_______Vote No on Division 1.
_______Abstain to vote on Division 1.
_________b. Vote Yes on Division 2.
___________Vote No on Division 2.
___________Abstain to vote on Division 2.
____________i. Vote Yes on Subdivision 1.
______________Vote No on Subdivision 1.
______________Abstain to vote on Subdivision 1.
___________ii. Vote Yes on Subdivision 2.
______________Vote No on Subdivision 2.
______________Abstain to vote on Subdivision 2.
_______________1. Vote Yes on Category 1.
_________________Vote No on Category 1.
_________________Abstain to vote on Category 1.
__________________2. Vote Yes on Category 2.
____________________Vote No on Category 2.
____________________Abstain to vote on Category 2.
_____________________a. Vote Yes on Subcategory 1.
_______________________Vote No on Subcategory 1.
_______________________Abstain to vote on Subcategory 1.
________________________i. Vote Yes on Chapter 1.
__________________________Vote No on Chapter 1.
__________________________Abstain to vote on Chapter 1.
___________________________1. Vote Yes on Paragraph 1.
_____________________________Vote No on Paragraph 1.
_____________________________Abstain to vote on Paragraph 1.
______________________________a. Vote Yes on Item 1.
________________________________Vote No on Item 1.
________________________________Abstain to vote on Item 1.
____________i. Vote Yes on Subdivision 3.
______________Vote No on Subdivision 3.
______________Abstain to vote on Subdivision 3.
_______________1. Vote Yes on Category 1.
_________________Vote No on Category 1.
_________________Abstain to vote on Category 1.
___________ii. Vote Yes on Subdivision 4.
______________Vote No on Subdivision 4.
______________Abstain to vote on Subdivision 4.
_____________________1. Vote Yes on Category 1.
_______________________Vote No on Category 1.
_______________________Abstain to vote on Category 1.
________________________a. Vote Yes on Subcategory 1.
__________________________Vote No on Subcategory 1.
__________________________Abstain to vote on Subcategory 1.
________________________b. Vote Yes on Subcategory 2.
__________________________Vote No on Subcategory 2.
__________________________Abstain to vote on Subcategory 2.
______a. Vote Yes on Division 3.
________Vote No on Division 3.
________Abstain to vote on Division 3.
_________1.
_____________________1. Vote Yes on Category 1.
_______________________Vote No on Category 1.
_______________________Abstain to vote on Category 1.
_____________________2. Vote Yes on Category 2.
_______________________Vote No on Category 2.
_______________________Abstain to vote on Category 2.
________________________a. Vote Yes on Subcategory 6.
__________________________Vote No on Subcategory 6.
__________________________Abstain to vote on Subcategory 6.
___________________________i. Vote Yes on Chapter 1.
_____________________________Vote No on Chapter 1.
_____________________________Abstain to vote on Chapter 1.
______________________________1. Vote Yes on Paragraph 1.
________________________________Vote No on Paragraph 1.
________________________________Abstain to vote on Paragraph 1.
B. Vote Yes on Section 2.
__Vote No on Section 2.
__Abstain to vote on Section 2.
C. Vote Yes on Section 3.
__Vote No on Section 3.
__Abstain to vote on Section 3.
____I. Vote Yes on Subsection 1.
______Vote No on Subsection 1.
______Abstain to vote on Subsection 1.
______II. Vote Yes on Subsection 2.
_________Vote No on Subsection 2.
_________Abstain to vote on Subsection 2.
__________a. Vote Yes on Division 1.
____________Vote No on Division 1.
____________Abstain to vote on Division 1.
_____________i. Vote Yes on Subdivision 1.
_______________Vote No on Subdivision 1.
_______________Abstain to vote on Subdivision 1.
________________1. Vote Yes on Category 1.
__________________Vote No on Category 1.
__________________Abstain to vote on Category 1.
___________________2. Vote Yes on Category 2.
_____________________Vote No on Category 2.
_____________________Abstain to vote on Category 2.
______________________a. Vote Yes on Subcategory 1.
________________________Vote No on Subcategory 1.
________________________Abstain to vote on Subcategory 1.
_________________________i. Vote Yes on Chapter 1.
___________________________Vote No on Chapter 1.
___________________________Abstain to vote on Chapter 1.

Last edited by rblampain; 07-28-2007 at 06:01 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Just ordered my first server! =) nr5 Linux - Software 14 12-28-2004 08:23 PM
Insert an ordered list into your message SidA Red Hat 0 06-19-2004 07:49 PM
Shell script for insert ip address into an ordered list of IPs inTrouble? Linux - Newbie 2 10-27-2003 02:21 AM
Slackware 9.1 can be pre-ordered! Noryungi Slackware 9 09-08-2003 12:06 PM
JavaScript inside a CGI for date validation....doesn't work!! vous Programming 3 08-27-2003 04:49 PM


All times are GMT -5. The time now is 02:20 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration