We just released an online shop.
On this page the selectboxes crashes Internet Explorer 7 on some computers. Never on my computer. Does anybody knows why?
Live link: http://velour.se/collection/women/tops/eloise
Update: turns out that the first like I posted did not crash.
But the following does: http://velour.se/collection/women/outerwear/irina
Screendump: http://skitch.com/jesperlind/nc4j2/tops-eloise-velour-ie7-bug
Original version:
<select id="sizeDD" onchange="javascript:SizeChange(this);"></select>
//Internet Explorer problem.
function SizeChange(e){
DrawAmountDD(GetAmountById(e.value));
}
Here's a bit of the code I think might be involved:
function DrawAmountDD(maxAmount){
/*var max = parseInt(maxAmount) > parseInt(maxShowAmount) ? maxShowAmount : maxAmount;
var html = "";
for(var i=1; i <= max; i++){
html += "<option value='" + i + "'>" + i + "</option>";
}
$("#amountDD").html(html);*/
var max = parseInt(maxAmount) > parseInt(maxShowAmount) ? maxShowAmount : maxAmount;
var ddlAmount = document.getElementById("amountDD");
ddlAmount.length=max;
for(var a=1; a <= max; a++){
ddlAmount.options[a-1].value = a;
ddlAmount.options[a-1].text = a;
}
}
Version 2:
<select id="sizeDD"></select>
<select id="amountDD"></select>
<script type="text/javascript">
var maxShowAmount = '5';
var colorSizeArr =
{ "colSize":
[
{ "color": "Black/Offwhite",
"specificId": "2",
"size": "XS",
"amount": "1" }
]
};
colorSizeArr.colSize.push(
{ "color": "Black/Offwhite",
"specificId": "13",
"size": "S",
"amount": "2" });
$(document).ready(function () {
var selectSizeDD = document.getElementById('sizeDD');
selectSizeDD.onchange = function () { sizeChange(selectSizeDD); };
});
function sizeChange(e) {
DrawAmountDD(GetAmountById(e.value));
}
function GetAmountById(specificId) {
for (var i = 0; i < colorSizeArr.colSize.length; i++) {
if (colorSizeArr.colSize[i].specificId == specificId) {
return colorSizeArr.colSize[i].amount;
}
}
return 1;
}
function DrawAmountDD(maxAmount) {
var max = parseInt(maxAmount) > parseInt(maxShowAmount) ? maxShowAmount : maxAmount;
var html = "";
for (var i = 1; i <= max; i++) {
html += "<option value='" + i + "'>" + i + "</option>";
}
$("#amountDD").html(html);
}
</script>
Update
I have not figured out exatcly why Internet Explorer 7 crashes on some computers. Any way the code above had not any thing to do with it. It was much more simpler. The browser crashed when clicking on a select-box with only one option. Like this:
<select id="amountDD">
<option value="1">1</option>
</select>
I found some info on this link where it says that the single option should have a selected attribute as well but it does seems to crash for us with out the attribute.
http://www.akselvoll.net/2007/08/ie7-crashes-when-clicking-on-drop-down.html