PDA

View Full Version : To check radio button based on values from responseText


rohandbhatte
10-29-2009, 04:51 PM
I am new to ajax and need help to select/check radio button based on the value from responseText. Bascially i have a form to edit help make changes. The form comprises of text box, drop down list and radio button.

Based on the value returned from servlet, I set these values to respective components using Document.getElemenetById("ID_Name").value=responsenumber.
response=xmlhttp.responseText.split(","); This sets value for text box and drop down list but radio button fail to get checked.

The code for radio button is

var a=response[18]; // Value from the database.
alert(a);

for(var i = 0; i < document.frm_eStudDetails.e_source.length; i++)

{

var b=document.frm_eStudDetails.e_source.value;

alert("A="a"B="+b);

if(a==b)

{

document.frm_eStudDetails.e_source.checked=true; // this never happens. even though text looks same.
break;

}

else

{


}

}
now I have tried a.text(), a.toString(), but nothing works while comparing the two.
Is there a way to convert the responseText to plain string or Should i change my approach to check the radio button.