Problem with JavaScript in IE7

I have been having a problem in IE7 and Internet Explorer 6, by where if you dynamically create a checkbox, set it to checked = true and then add it in to the HTML document, it loses it’s checked status.var newCheck = document.createElement(‘<input name=relatedSearchesChk>’);newCheck.type = “checkbox”; newCheck.onclick = updateCheckStatus;//Function to Call when clickednewCheck.relatedUrl = currSearch.Query;//Expando StringnewCheck.relatedObject = currSearch; //Expand ObjectnewCheck.checked = isChecked; //DOESN’t WORK. isChecked is just a local Booelan Variable.


This content originally appeared on Modern Web Development with Chrome and was authored by Paul Kinlan

<p>I have been having a problem in IE7 and Internet Explorer 6, by where if you dynamically create a checkbox, set it to checked = true and then add it in to the HTML document, it loses it's checked status.<p />var newCheck = document.createElement('<input name=relatedSearchesChk>');newCheck.type = "checkbox"; newCheck.onclick = updateCheckStatus;//Function to Call when clickednewCheck.relatedUrl = currSearch.Query;//Expando StringnewCheck.relatedObject = currSearch; //Expand ObjectnewCheck.checked = isChecked; //DOESN't WORK. isChecked is just a local Booelan Variable.tagCell1.appendChild(newCheck);<p />The closest related problem on the web that I found was this thread: <a href="http://forum.java.sun.com/thread.jspa?threadID=628633&messageID=3810937">Java Forums - Creating a checked Checkbox through javascript</a>. The solution in this thread works.<p />However I found another solution. Update the checked status after it has been added to the document. I have no idea why it works like this but it does work.<p />var newCheck = document.createElement(<input name=relatedSearchesChk>');newCheck.type = "checkbox"; newCheck.onclick = updateCheckStatus;//Function to Call when clickednewCheck.relatedUrl = currSearch.Query;//Expando StringnewCheck.relatedObject = currSearch; //Expand ObjecttagCell1.appendChild(newCheck);newCheck.checked = isChecked; //WORKS<p />If you know why this happens I would love to know: <a href="mailto:%20paul.kinlan@gmail.com">paul.kinlan@gmail.com</a><p /></p>


This content originally appeared on Modern Web Development with Chrome and was authored by Paul Kinlan


Print Share Comment Cite Upload Translate Updates
APA

Paul Kinlan | Sciencx (2005-10-23T00:00:00+00:00) Problem with JavaScript in IE7. Retrieved from https://www.scien.cx/2005/10/23/problem-with-javascript-in-ie7/

MLA
" » Problem with JavaScript in IE7." Paul Kinlan | Sciencx - Sunday October 23, 2005, https://www.scien.cx/2005/10/23/problem-with-javascript-in-ie7/
HARVARD
Paul Kinlan | Sciencx Sunday October 23, 2005 » Problem with JavaScript in IE7., viewed ,<https://www.scien.cx/2005/10/23/problem-with-javascript-in-ie7/>
VANCOUVER
Paul Kinlan | Sciencx - » Problem with JavaScript in IE7. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2005/10/23/problem-with-javascript-in-ie7/
CHICAGO
" » Problem with JavaScript in IE7." Paul Kinlan | Sciencx - Accessed . https://www.scien.cx/2005/10/23/problem-with-javascript-in-ie7/
IEEE
" » Problem with JavaScript in IE7." Paul Kinlan | Sciencx [Online]. Available: https://www.scien.cx/2005/10/23/problem-with-javascript-in-ie7/. [Accessed: ]
rf:citation
» Problem with JavaScript in IE7 | Paul Kinlan | Sciencx | https://www.scien.cx/2005/10/23/problem-with-javascript-in-ie7/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.