From ea435fe2fef4465d2923c4dfb3e16235464fb6e4 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Wed, 3 Sep 2008 09:30:10 +0000 Subject: [PATCH] JS does not work in IE. Grrrr! --- question/qengine.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/question/qengine.js b/question/qengine.js index 4702f985db..be5eeca373 100644 --- a/question/qengine.js +++ b/question/qengine.js @@ -5,12 +5,17 @@ question_flag_changer = { flag_state_listeners: new Object(), init_flag: function(checkboxid, postdata) { - // Convert the checkbox to a hidden input. - var input = document.getElementById(checkboxid); - var state = input.checked; - input.ajaxpostdata = postdata; - input.value = state ? 1 : 0; + // Create a hidden input - you can't just repurpose the old checkbox, IE + // does not cope - and put it in place of the checkbox. + var checkbox = document.getElementById(checkboxid); + var input = document.createElement('input'); input.type = 'hidden'; + checkbox.parentNode.appendChild(input); + checkbox.parentNode.removeChild(checkbox); + input.id = checkbox.id; + input.name = checkbox.name; + input.value = checkbox.checked ? 1 : 0; + input.ajaxpostdata = postdata; // Create an image input to replace the img tag. var image = document.createElement('input'); @@ -19,7 +24,7 @@ question_flag_changer = { question_flag_changer.update_image(image); input.parentNode.appendChild(image); - // Remove the label element. + // Remove the label. var label = document.getElementById(checkboxid + 'label'); label.parentNode.removeChild(label); -- 2.39.5