Checkboxes checken den IE7 nicht mit Javascript ein und haben noch keine Fehler

Okay, ich bin total verwirrt.

Ich habe ein Skript, das eine Reihe von Werten von einem JSON-Objekt empfängt und eine Reihe von Kontrollkästchen erstellt und diese Kontrollkästchen basierend auf ihren Werten entweder aktiviert oder deaktiviert.

Das Skript funktioniert korrekt in IE8, Firefox3, etc ... etc ...

Jedoch...

In IE7 kann das Skript die Kontrollkästchen nicht deaktivieren. Es zeigt keine Fehler an und soweit ich das beurteilen kann, läuft das Skript einwandfrei. Ich kreuze einfach keines der Kontrollkästchen an und weiß nicht warum ...

<code>shoppingCart['Update_Stock_Item_0_NRD%5FHAT2'] = {
            'propeller': {
                            'label'          : 'propeller',                             
                            'optionValues'   : {                                                    
                                                 'on' : {
                                                    'selected': 'selected'
                                                        },
                                                  'off' : {
                                                            'selected': ''
                                                          },
                                                        '' : new String()
                                                }
                        },
            'sunLogo': {
                            'label'          : 'sunLogo',                           
                            'optionValues'   : {                                                    
                                                 'on' : {
                                                    'selected': 'selected'
                                                        },
                                                  'off' : {
                                                            'selected': ''
                                                          },
                                                        '' : new String()
                                                }
                        },
            'MSLogo': {
                            'label'          : 'sunLogo',
                            'optionValues'   : {                                                    
                                                 'on' : {
                                                    'selected': 'selected'
                                                        },
                                                  'off' : {
                                                            'selected': ''
                                                          },
                                                        '' : new String()
                                                }
                        }                           
};
</code>

Funktion stockInit () {alert ("BEGIN: stockInit ()"); // TODO: Sie erhalten eine "Ein" - und eine "Aus" -Option. // Einer hat das Attribut "Ausgewählt" von "Ausgewählt", // und der andere das Attribut "Ausgewählt" von "" //. // Die Option mit dem Attribut "selected" von "" // generiert ein Kontrollkästchen, das nicht aktiviert ist. // // Die Option mit dem Attribut "selected" von "selected" // generiert ein Kontrollkästchen, das aktiviert ist. //
// Warum? Du fragst ... denn so ist das // Setup eben. for (var item in shoppingCart) {// // console.log ("Artikel wird verarbeitet:" + Artikel);

<code>        var optionContainer = document.getElementById(item + "_optionContainer");

        for(var option in shoppingCart[item])
        {
            if(option != "blank")
            {
                // // console.log("option: " + option);

                var currentOption = shoppingCart[item][option]['optionValues'];

                // // console.log("currentOption['on']['selected']: " + currentOption['on']['selected']);
                // // console.log("currentOption['off']['selected']: " + currentOption['off']['selected']);

                // Really you only have to check the one, but just to be through-o
                var selected = (currentOption['on']['selected'] == 'selected') ? true : false;
                selected = (currentOption['off']['selected'] == 'selected') ? false : true;

                var label = document.createElement("LABEL");
                var labelText = document.createTextNode(shoppingCart[item][option]['label']);
                var optionInput = document.createElement("INPUT");

                var hiddenInput = document.createElement("INPUT");

                optionInput.setAttribute("type", "checkbox");
                optionInput.checked = selected;

                optionInput.setAttribute("id", option);
                alert(optionInput.id);
                alert(optionInput.checked);

                hiddenInput.setAttribute("type", "hidden");
                hiddenInput.setAttribute("name", option);
                hiddenInput.setAttribute("id", option + "_hiddenValue");
                hiddenInput.setAttribute("value", (optionInput.checked) ? "on" : "off");

                label.appendChild(optionInput);
                label.appendChild(labelText);
                label.appendChild(hiddenInput);

                (function(id)
                {
                    optionInput.onclick = function() {

                        var hiddenInput = document.getElementById(id + "_hiddenValue");

                        hiddenInput.setAttribute("value", (this.checked == true) ? "on" : "off");
                        alert("this.id: " + this.id);
                        alert("this.checked: " + this.checked);
                    }
                })(optionInput.id);

                optionContainer.appendChild(label);


            }
        }
        // // console.log("processing item of " + item + " complete");
    }
    alert("END: stockInit()");
}
</code>

Und bitte fragen Sie nicht, warum ich die Dinge so mache ... alles, was ich Ihnen wirklich sagen kann, ist, dass ich keinen Zugriff auf den Backend-Code habe ... also bekomme ich, was ich bekomme ...

Antworten auf die Frage(1)

Ihre Antwort auf die Frage