SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Buffalo, NY
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Help! Need to Identify a specific selection within Radio Group!

    This is my first time in this forum, and I am hoping that I may be able to get an anser to this imprtant question.

    I have a form that I am validating all fields. I successfully completed the Javascript functions for that...the problem is that within this validation I need to check if a specific selection was made within a radio group (array) and if , let's say "Yes" was selected, then another radio group would not be required.

    Here is the code snippet that I am working with, mind you this is part of the whole function:

    Code:
    var isbrnchChecked = false;
    var brnch = document.forms['f2'].elements['Branch'];
    for ( var l = 0; l < brnch.length; l++ ) {
            if (brnch[l].checked) isbrnchChecked = true;
        }    
    
        if (!isbrnchChecked) {
            thismessage = thismessage + "The Transferred to branch question must be answered before continuing!";
    	newAlert("Required Field",thismessage,4,0);
    	return false;
        }
    
    	for ( var m = 0; m < brnch.length; m++ ) {
            		if (brnch[m].checked) var radioVal = brnch[m].value;
       			if (radioVal=="yes") {
            		thismessage = thismessage + "The Valid call to branch question must be answered before continuing!";
    			newAlert("Required Field",thismessage,4,0);
            		return false;
    	}
    }
    This code is not working, but I hope it give you an idea of what I am trying to accomplish..

    I have not figured out how to check the 2nd group for selection once we have identified the first group ???

    Thank you!

  2. #2
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Buffalo, NY
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was able to find the answer on my own...maybe it was a Friday brain freeze...but I made some adjustment to the If statment which was looking for the proper array element..

    Thank you all anyway!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •