jebaraj Posted September 27, 2011 Share Posted September 27, 2011 Hi, I have added an validation script for Pizza menu. Validation working fine in all browsers except IE. When I working in IE8 it throws an error "length is null or not an object error in IE8". Please help me. See Java script code below: <script> function UnCheckRadios(radioButtonGroupName) { var formName = "frmOrder"; var form = document.forms[formName]; alert(form); var noOfRadioButtons=form[radioButtonGroupName].length; for(var x=0;x<noOfRadioButtons;x++) { chk=form[radioButtonGroupName][x].checked=false; } } </script> PHP code: <input type="radio" id="<?=$subitem['subgroup_id'];?>_comboleft" name="<?=$subitem['subgroup_id'];?>_comboleft" value="<?=$subitem['id'];?>:Left Side" onclick="UnCheckRadios('<?=$subitem["subgroup_id"];?>_combowhole');"> [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/247931-length-is-null-or-not-an-object-error-in-ie8/ Share on other sites More sharing options...
.josh Posted September 28, 2011 Share Posted September 28, 2011 In and of itself, the function works fine in IE8. Clicking on something that calls your function clears it just fine. Here is test code I used: <script type='text/javascript'> function UnCheckRadios(radioButtonGroupName) { var formName = "frmOrder"; var form = document.forms[formName]; var noOfRadioButtons=form[radioButtonGroupName].length; for(var x=0;x<noOfRadioButtons;x++) { chk=form[radioButtonGroupName][x].checked=false; } } </script> <form name='frmOrder'> <input type="radio" name="colors" id="red" />Red<br /> <input type="radio" name="colors" id="blue" />Blue<br /> <input type="radio" name="colors" id="green" />Green<br /> </form> <button type="button" onclick="UnCheckRadios('colors')">uncheck</button> Look at the output of your form radio buttons, make sure that your php script is outputting what it is supposed to be outputting (the right radio button names). Also make sure your form is named "frmOrder". Quote Link to comment https://forums.phpfreaks.com/topic/247931-length-is-null-or-not-an-object-error-in-ie8/#findComment-1273584 Share on other sites More sharing options...
jebaraj Posted September 29, 2011 Author Share Posted September 29, 2011 Thanks for your reply. I have fixed this issue. This is because of radio button name starts with Number (Eg: 2207_comboleft). IE not supporting this. I have fixed by adding a Alphabet at starting name. Quote Link to comment https://forums.phpfreaks.com/topic/247931-length-is-null-or-not-an-object-error-in-ie8/#findComment-1273836 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.