V1-Hyper
Well-known member
- Joined
- Feb 25, 2010
- Messages
- 309
- Reaction score
- 0
Hello all,
This is about my problem with the new Cryonite Grinding Calculator on The Hitchhiker's Guide to PG working in Opera and IE but not yet in FF, Chrome and Safari.
Neither Dreamweaver DS5 v11 nor Expression Web v3 prompt any browser incompatibility issues with this code, so I have no clue what’s itching here. But I read that different browsers sometimes use different JS commands for certain actions, but these details lie beyond me.
Maybe someone with JS skills can help? Thanks for any comments
This is the xhtml code I use:
---Header Section---
<script type="text/javascript">
//Initialize var’s
var boost='0';
var sq='1';
var act='1';
function CryGrinder(boost,sq,act)
{
if (!document.getElementById) {return true;} //Browser handles getElementById?
var b=parseFloat(boost); // Cry Booster
var s=parseInt(sq); // Number of squad members
var a=parseInt(act); // of which actively grind
//check: selected active members never greater than selected squad members
if (a>s)
{
for (var i=1; i<=5; i++) {document.getElementById('act'+String(i)).removeAttribute('selected');}
document.getElementById('act'+sq).setAttribute('selected', "selected");
a=s;
}
// when sq changes, disable items of active members drop list greater than sq
for (var i=1; i<=s; i++) {document.getElementById('act' +String(i)).removeAttribute('disabled');}
for (var i= (s+1); i<=5; i++) {document.getElementById('act' +String(i)).setAttribute('disabled', "disabled");}
// calc cryonite and output
document.getElementById('output1').innerText=String(Math.round(b+ 100/s)+'%');
document.getElementById('output2').innerText=String(Math.round((b+100/s)*a)+'%');
}
</script>
---corresponding elements in Body Section---
<select id="Booster" onchange="return CryGrinder(Booster.value,sqMembers.value,activeMembers.value)">
<option value="0" selected="selected">no</option>
<option value="10">10%</option>
<option value="25">25%</option>
<option value="33.3">33%</option>
<option value="100">100%</option>
</select>
<select id="sqMembers" onchange="return CryGrinder(Booster.value,sqMembers.value,activeMembers.value)">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select id="activeMembers" onchange="return CryGrinder(Booster.value,sqMembers.value,activeMembers.value)">
<option id="act1" value="1" selected="selected">1</option>
<option id="act2" value="2" disabled="disabled">2</option>
<option id="act3" value="3" disabled="disabled">3</option>
<option id="act4" value="4" disabled="disabled">4</option>
<option id="act5" value="5" disabled="disabled">5</option>
</select>
<input type="text" id="output1" name="text1" readonly="readonly" />
<input type="text" id="output2" name="text2" readonly="readonly" />
This is about my problem with the new Cryonite Grinding Calculator on The Hitchhiker's Guide to PG working in Opera and IE but not yet in FF, Chrome and Safari.
Neither Dreamweaver DS5 v11 nor Expression Web v3 prompt any browser incompatibility issues with this code, so I have no clue what’s itching here. But I read that different browsers sometimes use different JS commands for certain actions, but these details lie beyond me.
Maybe someone with JS skills can help? Thanks for any comments
This is the xhtml code I use:
---Header Section---
<script type="text/javascript">
//Initialize var’s
var boost='0';
var sq='1';
var act='1';
function CryGrinder(boost,sq,act)
{
if (!document.getElementById) {return true;} //Browser handles getElementById?
var b=parseFloat(boost); // Cry Booster
var s=parseInt(sq); // Number of squad members
var a=parseInt(act); // of which actively grind
//check: selected active members never greater than selected squad members
if (a>s)
{
for (var i=1; i<=5; i++) {document.getElementById('act'+String(i)).removeAttribute('selected');}
document.getElementById('act'+sq).setAttribute('selected', "selected");
a=s;
}
// when sq changes, disable items of active members drop list greater than sq
for (var i=1; i<=s; i++) {document.getElementById('act' +String(i)).removeAttribute('disabled');}
for (var i= (s+1); i<=5; i++) {document.getElementById('act' +String(i)).setAttribute('disabled', "disabled");}
// calc cryonite and output
document.getElementById('output1').innerText=String(Math.round(b+ 100/s)+'%');
document.getElementById('output2').innerText=String(Math.round((b+100/s)*a)+'%');
}
</script>
---corresponding elements in Body Section---
<select id="Booster" onchange="return CryGrinder(Booster.value,sqMembers.value,activeMembers.value)">
<option value="0" selected="selected">no</option>
<option value="10">10%</option>
<option value="25">25%</option>
<option value="33.3">33%</option>
<option value="100">100%</option>
</select>
<select id="sqMembers" onchange="return CryGrinder(Booster.value,sqMembers.value,activeMembers.value)">
<option value="1" selected="selected">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<select id="activeMembers" onchange="return CryGrinder(Booster.value,sqMembers.value,activeMembers.value)">
<option id="act1" value="1" selected="selected">1</option>
<option id="act2" value="2" disabled="disabled">2</option>
<option id="act3" value="3" disabled="disabled">3</option>
<option id="act4" value="4" disabled="disabled">4</option>
<option id="act5" value="5" disabled="disabled">5</option>
</select>
<input type="text" id="output1" name="text1" readonly="readonly" />
<input type="text" id="output2" name="text2" readonly="readonly" />