Finding radio button is selected or not in gridview

June 15, 2007

I have develop one javascript. it’s  finding radio button value is selected or not in grid.

<script type=”text/javascript” language=”JavaScript”>functionIsFeedbackMandatory(){var Emlements = document.forms[0];var IsAtleastOneChecked = false;var i=0;var CountRadioButton = 0;// Loop through all the elements

for(i=0;i<Emlements.length;i++){// Check for Radio buttonif(Emlements[i].type == “radio”){// If radio buttton is checked than make IsAtleastOneChecked = true

if(Emlements[i].checked == true)IsAtleastOneChecked = true;// Increament CountRadioButton each time you find radio buttonCountRadioButton = eval(CountRadioButton + 1);// We have 5 radio buttons per datagrid row. // When count becomes 5 means we have checked a row

// Set IsAtleastOneChecked = false// Set CountRadioButton = 0// So we have clear our parameters for next rowif(CountRadioButton == 5){// Check if in current row none of the radio button is selected than show alert message.// break the llop

if(IsAtleastOneChecked == false){alert(“Please select atleast one option for each feedback parameter.”);return false;

break;}// Clear CountersCountRadioButton =0;IsAtleastOneChecked = false;}}}

}

</script>I called this function serversideif (SessionInfo.IsFeedbackMandatory == true){ibtnSave.Attributes.Add(“onclick”, “return IsFeedbackMandatory();”);}

Entry Filed under: JavaScript. .

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Blog Stats

Top Clicks