|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Javascript guru help
Hi,
I have two groups pre conference and main conference and i have 3 groups of radio buttons in preconference and one set of radio button in main conference Code:
Preconference group Group one radion buttons <input type="radio" name="Groupone" value="Introduction to Olympic Weightlifting" /> <input type="radio" name="Groupone" value="Advanced Concepts In Sport-Specific Speed Development" /> <input type="radio" name="Groupone" value="Strength Training and Conditioning for Tennis" /> <br><br> Group two radion buttons <input type="radio" name="Grouptwo" value="Training Special Populations" /> <input type="radio" name="Grouptwo" value="Role of Nutritional Supplementation on Energy Expenditure,Athletic Performance, and Body Composition" /> <input type="radio" name="Grouptwo" value="Strength and Conditioning Programs for the Golf Athlete" /> Group three radio buttons <input type="radio" name="Groupthree" value="Training the Basketball Athlete:Two Case Studies" /> <input type="radio" name="Groupthree" value="Extreme Balance Training for All Populations" /> <br><br> Main Conference Group Group Four <input type="radio" id="AD" name="Conf" value="All/any day" /> <input type="radio" id="OD" name="Conf" value="One day" /> the following code works fine if the user doesnt select one of the radio button in either pre-conference or main conference group Code:
var arrGroups=new Array(document.forms["frm1"].elements["Groupone"], document.forms["frm1"].elements["Grouptwo"], document.forms["frm1"].elements["Groupthree"], document.forms["frm1"].elements["Conf"]);
var checkedCount=0;
for (var i=0; i<arrGroups.length; i++)
{
for (var j=0; j<arrGroups[i].length; j++)
{
checkedCount += (arrGroups[i][j].checked)?1:0;
}
}
if (checkedCount == 0)
{
alert(alertMsg += "- Select either Pre-conference symposia or Main conference or Both.\n\n\nThese fields have been highlighted for your attention.");
return false;
}
Now i have to add a radio button to each group so now if the user selects none radio button in pre-conference then i have to pop up a alert saying he didnt make the choice same applies if the user selects a none radio button in main conference then pop up alert advising him to make a selection in preconference or main conference . Code:
------------------------------------ Preconference group Group one radion buttons <input type="radio" name="Groupone" value="Introduction to Olympic Weightlifting" /> <input type="radio" name="Groupone" value="Advanced Concepts In Sport-Specific Speed Development" /> <input type="radio" name="Groupone" value="Strength Training and Conditioning for Tennis" /> <input type="radio" name="Groupone" value="0" />None</td> <br><br> Group two radion buttons <input type="radio" name="Grouptwo" value="Training Special Populations" /> <input type="radio" name="Grouptwo" value="Role of Nutritional Supplementation on Energy Expenditure,Athletic Performance, and Body Composition" /> <input type="radio" name="Grouptwo" value="Strength and Conditioning Programs for the Golf Athlete" /> <input type="radio" name="Grouptwo" value="0" />None</td> Group three radio buttons <input type="radio" name="Groupthree" value="Training the Basketball Athlete:Two Case Studies" /> <input type="radio" name="Groupthree" value="Extreme Balance Training for All Populations" /> <input type="radio" name="Groupthree" value="0" />None</td> <br><br> --------------------------- Main conference Group Group Four <input type="radio" id="AD" name="Conf" value="All/any day" /> <input type="radio" id="OD" name="Conf" value="One day" /> <input type="radio" name="Conf" value="0" />None</td> ------------------------------------------ Can someone tell me what change i have to make in the above code to make this happen thanks, sammy |
|
#2
|
|||
|
|||
|
got it working ;)
Hi ,
i got it working had to do (-1) to the length the code is as follows Code:
var arrGroups=new Array(document.forms["frm1"].elements["Groupone"], document.forms["frm1"].elements["Grouptwo"], document.forms["frm1"].elements["Groupthree"], document.forms["frm1"].elements["Conf"]);
var checkedCount=0;
for (var i=0; i<arrGroups.length; i++)
{
for (var j=0; j<arrGroups[i].length-1; j++)
{
checkedCount += (arrGroups[i][j].checked)?1:0;
}
}
if (checkedCount == 0)
{
alert(alertMsg += "- Select either Pre-conference symposia or Main conference or Both.\n\n\nThese fields have been highlighted for your attention.");
return false;
}
cheers its working thanks, sammy |
|
#3
|
||||
|
||||
|
see? you can solve your problem yourself if you want...
![]() |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Javascript guru help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|