softwarescience
Programmer
Hello
I seem to have hit a mind-bendingly awkward problem using GetElementsByName to get a radio button group and select a particular item.
Following is a portion of the code I am trying to make work.
As shown, I pass the element name (I've tried id as well) to a modal popup which then returns a value.
I have found absolutely no way of ensuring that the correct radio button is checked after the popup window.
Surely it can't be that difficult to programmatically select an existing radio button from a group.
Any suggestions as to what I'm doing wrong would be greatly appreciated.
I seem to have hit a mind-bendingly awkward problem using GetElementsByName to get a radio button group and select a particular item.
Following is a portion of the code I am trying to make work.
Code:
function doDataPopup(sArgs, sType) {
var RetVal;
var oObj;
RetVal = window.showModalDialog("fraPopup.aspx", "", "center: Yes; help: No; resizable: Yes; status: No;");
switch (sType) {
case "Radio" :
alert(sArgs);
oObj = document.getElementsByName(sArgs);
if (oObj != null){
//never gets in here
alert('Found obj');
oObj[RetVal].checked=true;
}
if (RetVal=='1'){
alert(sArgs + '_1');
oObj = document.getElementById(sArgs + '_1');
if (oObj != null){
//never gets in here
alert('Found obj 1');
oObj.checked = true;
}
}else{
alert(sArgs + '_0');
oObj = document.getElementById(sArgs + '_0');
if (oObj != null){
//never gets in here
alert('Found obj 0');
oObj.checked = true;
}
}
break;
default :
if (RetVal != null){
oObj = document.getElementById(sArgs);
if (oObj != null){
oObj.value = RetVal;
}
}
}
}
As shown, I pass the element name (I've tried id as well) to a modal popup which then returns a value.
I have found absolutely no way of ensuring that the correct radio button is checked after the popup window.
Surely it can't be that difficult to programmatically select an existing radio button from a group.
Any suggestions as to what I'm doing wrong would be greatly appreciated.