Question

The following jQuery code actually works fine in MS IE8 but returns ‘undefined’ in MS IE6.

I have also checked other questions in Stack Overflow relating to my query but cannot find any info relating to IE6. I need this code to work in both browsers (IE6 and IE8).

I have the following HTML setup for my radiogroup:

<input type="radio" name="f10" value="abc123"/>

I also have the following code that seems to work fine in IE8 but not in IE6:

function processJob(){
  if ($("input[name=f10]:checked").val() != undefined){
     isDelgateFlag = "Y";
     var delgSelection = $("input[name=f10]:checked").val();
  }
  else {
    isDelgateFlag = "N";
    $('#dialogdelegate').dialog('open');
    alert("Please make a selection.");
  }
}

As mentioned, the $("input[name=f10]:checked").val() seems to return a value in IE8 but returns ‘undefined’ in IE6.

How can I cater for both browsers?

Was it helpful?

Solution

Quote it f10

if ($("input[name='f10']:checked").val() != undefined){

OR Give a class to the radio button say foo and

alert($('.foo:checked').val());

OTHER TIPS

Thanks to the above responses. After upgrading both jQuery and jQuery UI libraries to the latest versions, this seemed to have solved my problems in both IE6 and IE8 browsers.

Thanks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top