Mozilla firefox issue.
-
Hello, Thank you for reading this post. I am new to Javascript and ASP.NET development so please bear with me. I have a page that renders fine in IE but the same functionality gives me error in Firefox. I have a form which has a bunch of check boxes and there is a a particular checkbox lets call it ABC, and clicking on it, it needs to uncheck the other boxes, and if other check box is clicked, it shud uncheck the the ABC checkbox. My app works fine in IE but not in Firefox. I know there are a few keywords that is Microsoft proprietary, and is not all browser friendly, but i cannot figure out how to change it. Here is my code below. All help is appreciated. function ValidateCheckedValues( ctrl , isChecked ) { // Purpose : This function is called when the user clicks on any checkbox in the equipment requirements table on the page // If the user clicks on the "ABC" checkbox it clears all the check boxes for that meeting, // but if the user checked any other checkbox, it removes the check from the "ABC" checkbox try { if( ctrl.parentElement.attributes("SubCode").value == "NONE" ) { if( isChecked ) { for( counter = 3 ; counter < ctrl.parentElement.parentElement.parentElement.children.length ; counter++ ) { ctrl.parentElement.parentElement.parentElement.children( counter ).children( 0 ).children( 0 ).checked = false; } ctrl.checked = true; } } else { if( isChecked ) { for( counter = 3 ; counter < ctrl.parentElement.parentElement.parentElement.children.length ; counter++ ) { if( ctrl.parentElement.parentElement.parentElement.children( counter ).children( 0 ).attributes("SubCode").value == "NONE" ) { ctrl.parentElement.parentElement.parentElement.children( counter ).children( 0 ).children( 0 ).checked = false; } } } } } catch( ex ) { alert( ex.message ); } }
-
Hello, Thank you for reading this post. I am new to Javascript and ASP.NET development so please bear with me. I have a page that renders fine in IE but the same functionality gives me error in Firefox. I have a form which has a bunch of check boxes and there is a a particular checkbox lets call it ABC, and clicking on it, it needs to uncheck the other boxes, and if other check box is clicked, it shud uncheck the the ABC checkbox. My app works fine in IE but not in Firefox. I know there are a few keywords that is Microsoft proprietary, and is not all browser friendly, but i cannot figure out how to change it. Here is my code below. All help is appreciated. function ValidateCheckedValues( ctrl , isChecked ) { // Purpose : This function is called when the user clicks on any checkbox in the equipment requirements table on the page // If the user clicks on the "ABC" checkbox it clears all the check boxes for that meeting, // but if the user checked any other checkbox, it removes the check from the "ABC" checkbox try { if( ctrl.parentElement.attributes("SubCode").value == "NONE" ) { if( isChecked ) { for( counter = 3 ; counter < ctrl.parentElement.parentElement.parentElement.children.length ; counter++ ) { ctrl.parentElement.parentElement.parentElement.children( counter ).children( 0 ).children( 0 ).checked = false; } ctrl.checked = true; } } else { if( isChecked ) { for( counter = 3 ; counter < ctrl.parentElement.parentElement.parentElement.children.length ; counter++ ) { if( ctrl.parentElement.parentElement.parentElement.children( counter ).children( 0 ).attributes("SubCode").value == "NONE" ) { ctrl.parentElement.parentElement.parentElement.children( counter ).children( 0 ).children( 0 ).checked = false; } } } } } catch( ex ) { alert( ex.message ); } }
what is the error ?
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
-
what is the error ?
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
please note:this works fine in IE but throws errors like ctrl.parentElement has no properties.Please let me know what error is happening here. I changed the parentElement to parentNode and the children to childNodes but it just will not work for firefox. Iam a Software support person so do not have an indepth handle on the workings of .NET or Javascript. Thank you.
-
please note:this works fine in IE but throws errors like ctrl.parentElement has no properties.Please let me know what error is happening here. I changed the parentElement to parentNode and the children to childNodes but it just will not work for firefox. Iam a Software support person so do not have an indepth handle on the workings of .NET or Javascript. Thank you.
"ctrl.parentElement.parentElement.parentElement" Code like this is very bad. It assumes that the ctrl has 3 parents and will crash if it does not. If your problem is in Firefox, you should download Firebug, which will let you debug your javascript inside firefox and see exactly what properties are present and what their values are.
Ridge Howison wrote:
so do not have an indepth handle on the workings of .NET or Javascript
Then you're the wrong person for this job, why are you doing it ? Why did my answer get voted as bad ?
Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
-
Hello, Thank you for reading this post. I am new to Javascript and ASP.NET development so please bear with me. I have a page that renders fine in IE but the same functionality gives me error in Firefox. I have a form which has a bunch of check boxes and there is a a particular checkbox lets call it ABC, and clicking on it, it needs to uncheck the other boxes, and if other check box is clicked, it shud uncheck the the ABC checkbox. My app works fine in IE but not in Firefox. I know there are a few keywords that is Microsoft proprietary, and is not all browser friendly, but i cannot figure out how to change it. Here is my code below. All help is appreciated. function ValidateCheckedValues( ctrl , isChecked ) { // Purpose : This function is called when the user clicks on any checkbox in the equipment requirements table on the page // If the user clicks on the "ABC" checkbox it clears all the check boxes for that meeting, // but if the user checked any other checkbox, it removes the check from the "ABC" checkbox try { if( ctrl.parentElement.attributes("SubCode").value == "NONE" ) { if( isChecked ) { for( counter = 3 ; counter < ctrl.parentElement.parentElement.parentElement.children.length ; counter++ ) { ctrl.parentElement.parentElement.parentElement.children( counter ).children( 0 ).children( 0 ).checked = false; } ctrl.checked = true; } } else { if( isChecked ) { for( counter = 3 ; counter < ctrl.parentElement.parentElement.parentElement.children.length ; counter++ ) { if( ctrl.parentElement.parentElement.parentElement.children( counter ).children( 0 ).attributes("SubCode").value == "NONE" ) { ctrl.parentElement.parentElement.parentElement.children( counter ).children( 0 ).children( 0 ).checked = false; } } } } } catch( ex ) { alert( ex.message ); } }
parentElement
should beparentNode
[^] 2) IE tends to not insert text nodes for whitespace in the HTML; Firefox does. This doesn't normally make any difference, but your code is making some very specific assumptions as to how many children certain elements will have... this is probably going to trip you up sooner or later. Stop it. Either give the target elementsid
s and use document.getElementById()[^] to retrieve them, or get a library like jQuery[^] to help you traverse the DOM in a safe, sane manner.
Citizen 20.1.01
'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'