iEntry 10th Anniversary Forum Rules Search
WebProWorld
Register FAQ Calendar Mark Forums Read
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

Share Thread:

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-21-2004, 11:50 PM
WebProWorld Member
 
Join Date: Jul 2004
Location: 03301
Posts: 28
elso RepRank 0
Default Cross Browser Help

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;

}

-->
form elements:
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>
Can someone assist me in making this compatable with NS?

Thank you
Nelson
Reply With Quote
  #2 (permalink)  
Old 07-22-2004, 04:12 AM
WebProWorld Veteran
 
Join Date: Apr 2004
Posts: 447
HardCoded RepRank 0
Default

What craps out? Just a quick guess, id="textarea" should be id="toption1"
Reply With Quote
  #3 (permalink)  
Old 07-22-2004, 08:20 AM
WebProWorld 1,000+ Club
 
Join Date: Aug 2003
Location: Edmonton, AB, Canada
Posts: 1,527
mikmik RepRank 2mikmik RepRank 2
Default

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
Reply With Quote
  #4 (permalink)  
Old 07-22-2004, 11:00 AM
WebProWorld Member
 
Join Date: Jul 2004
Location: 03301
Posts: 28
elso RepRank 0
Default opps

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...
Reply With Quote
  #5 (permalink)  
Old 07-22-2004, 02:44 PM
WebProWorld Veteran
 
Join Date: Apr 2004
Posts: 447
HardCoded RepRank 0
Default

Who knows. IE likes to be slack about things, so it probably thinks the name is the id.
Reply With Quote
  #6 (permalink)  
Old 07-26-2004, 01:38 PM
swstyles's Avatar
WebProWorld Member
 
Join Date: Aug 2003
Location: Phoenix, AZ
Posts: 96
swstyles RepRank 0
Default

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
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 12:34 AM.



Search Engine Optimization by vBSEO 3.3.0