|
|
||||||
|
||||||
| Index Link To US Private Messages Archive FAQ RSS | ||||||
| Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome. |
Share Thread: & Tags
|
||||
|
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hello
I am not very knowledgeable with JavaScript beyond working from examples. I have successfully seeked out bits and pieces of JS to assemble on my page to function exactly the way I want. It works perfect in Internet Explorer but craps out in Netscape. Here is the script that functions perfect in IE: Header (less the script tags as I have this set external) Code:
<!--
function change()
{
var topoption=document.getElementById('toption1');
topoption.value='';
var tempArr=new Array();
if(document.getElementById('brown').checked)
tempArr[tempArr.length]=new Array((parseInt(document.getElementById('br').value,10)==document.getElementById('br').value)?document.getElementById('br').value:0,'Brown');
if(document.getElementById('green').checked)
tempArr[tempArr.length]=new Array((parseInt(document.getElementById('gr').value,10)==document.getElementById('gr').value)?document.getElementById('gr').value:0,'Green');
if(document.getElementById('blue').checked)
tempArr[tempArr.length]=new Array((parseInt(document.getElementById('blu').value,10)==document.getElementById('blu').value)?document.getElementById('blu').value:0,'Blue');
if(document.getElementById('white').checked)
tempArr[tempArr.length]=new Array((parseInt(document.getElementById('wht').value,10)==document.getElementById('wht').value)?document.getElementById('wht').value:0,'White w/Gold Trim');
l=0;
for(i=0;i<tempArr.length;i++)
{
if((tempArr[i][0]+'').length>l)l=(tempArr[i][0]+'').length;
}
d=2;
spaces=new Array('',' ',' ',' ',' ',' ');
var total=0;
for(i=0;i<tempArr.length;i++)
{
topoption.value+=tempArr[i][0]+spaces[d+l-(tempArr[i][0]+'').length]+tempArr[i][1]+'\n\r';
total+=parseInt(tempArr[i][0],10);
}
document.getElementById('quantity').value=total;
}
-->
Code:
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><div align="center">Size
<hr>
</div>
</td>
<td><div align="center">Quantity
<hr>
</div>
</td>
<td><font size="-1">[img]../../assets/spacer.gif[/img]</font></td>
<td><div align="center">Size
<hr>
</div>
</td>
<td><div align="center">Quantity
<hr>
</div>
</td>
<td rowspan="4"><font size="-1">[img]../../assets/spacer.gif[/img]</font></td>
<td rowspan="3"><textarea name="toption1" cols="25" rows="6" readonly id="textarea"></textarea>
</td>
</tr>
<tr>
<td><input name="brown" type=CHECKBOX id="brown" value="Brown" onClick="change();">
Brown</td>
<td><div align="center">
<input name="br" type=TEXT id="br" size=3 maxlength=3 onChange="change();">
</div>
</td>
<td></td>
<td><input name="blue" type=CHECKBOX id="blue" value="Blue" onClick="change();">
Blue</td>
<td><div align="center">
<input name="blu" type=TEXT id="blu" size=3 maxlength=3 onChange="change();">
</div>
</td>
</tr>
<tr>
<td rowspan="2"><input name="green" type=CHECKBOX id="green" value="Green" onclick="change();">
Green</td>
<td rowspan="2"><div align="center">
<INPUT NAME="gr" TYPE=TEXT id="gr" SIZE=3 MAXLENGTH=3 onchange="change();">
<font face="Arial"> </font> </div>
</td>
<td rowspan="2"></td>
<td rowspan="2" nowrap><input name="white" type=CHECKBOX id="white" value="White" onClick="change();">
White</td>
<td rowspan="2"><div align="center">
<div align="center">
<input name="wht" type=TEXT id="wht" size=3 maxlength=3 onChange="change();">
</div>
</div>
</td>
</tr>
<tr>
<td><div align="center">Total Quantity
<input name="quantity" type="text" id="quantity" value="0" size="4" readonly="">
</div>
</td>
</tr>
</table>
Thank you Nelson |
|
|||
|
For what it is worth, and javascript, my knowledge IS really only worth 2 cents...
Why dont you decug it in Netscape, they have several javascript dubbuggers available. Start out, is it a syntax, or runtime error. Most likely runtime is my guess because I understand that even different versions of the same browser, let alone IE vs Mozilla/Netscape use different run libraries. But I gotta say, I do know that debugging starts with a list of the errors generated, not manually searching the code...I think :O))) But this is over my head somewhat, I am trying to learn also LOL |
|
|||
|
Ok.... I'm a dummy here:-) I should have caught this myself... Of course now comes the question of Why didn't this phase IE? My error was a very straight foward goof that I think should have confused IE also...
|
|
||||
|
slack is not the way to describe this.
IE has the tendency to finish code. If you have poor html skills, IE will try to render your code to what it thinks you were trying to say. Some of the same rules apply to scripting. IE makes a bad coder look good. I wish IE had a code debugger like netscape/mozilla has. It would make life a whole lot easier for us MS guys.
__________________
Daniel M: South West Styles/STEELid daniel@steelid.com http://www.steelid.com http://www.thephototool.com |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
WebProWorld |
Advertise |
Contact Us |
About |
Forum Rules |
MVP's |
Archive |
Newsletter Archive |
Top |
WebProNews
WebProWorld is an iEntry, Inc. ® site - © 2009 All Rights Reserved Privacy Policy and Legal iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 |