Click to See Complete Forum and Search --> : javascript problem with explorer


reche
05-29-2003, 05:01 PM
Dear all,
I have a javascrript that takes tree values from from a form, does some calculations and then return the value of the calculations into a window of the form. This javascript works great in netscape, but it does not work with intenet explorer. Moreover, it does not pass the calculated value to a cgi script that I am working on. The javascrirpt is at the url http://mif.dfci.harvard.edu/temp_javas.html, and the code is in the body of this e-mail
If anyone see where is the problem I will be glad to hear about. thanks in advance for any help

cheers

<HTML>
<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- hide from old browsers

// **********************************************************************
//
// Here are the javascripts ...
//
// **********************************************************************

function modMotifObject( incoming )
{
// I hope this works ....
var ta = document.MHCRank.coverage;
var calcArray = new Array();
var motCoverage = new Number( 0.0 );
if (motifObject[incoming] == 0)
{
motifObject[incoming] = 1;
}
else
{
motifObject[incoming] = 0;
}
// calculateCoverage();
for ( motif in motifObject ) {
if (motifObject[motif] == 1)
calcArray.push( motif );
}
var motString = new String(calcArray);
//
// A2 A3 A24 B7 B15 B39 B44
//
// if (motString == 'A2') motString = 'yes';
if (motString == "A2") motCoverage = 43.75;
if (motString == "B7") motCoverage = 30.64;
if (motString == "A2,B7") motCoverage = 66.07;
if (motString == "A2,A3,A24,B7,B15,B39,B44") motCoverage = 85.57;
var outString = new String(motCoverage.toString() + " %");
ta.value = outString;
// document.write("<p>"+ motString+"</p>" );
}

var motifObject = {
A2:0,
B7:0
}

// end script hiding -->

</SCRIPT>

</HEAD>
<BODY bgcolor="white">
<FORM action="/cgi-bin/x.cgi" name="MHCRank" method="POST" enctype="multipart/form-data" >
<table border="0">
<tr>
<th colspan=3 bgcolor="#5F9EA0">Select Value</th>
</tr>
<tr>
<td>
<input name="antigen" type="checkbox" value="A2" onClick='modMotifObject( this.value )'>
<b><font color =red>A2:</b></font>
</td>
</tr>
<tr>
<td>
<input name="antigen" type="checkbox" value="B7" onClick='modMotifObject( this.value )'>
<b><font color =red>B7:</b></font>
</tr>

<tr>
<th colspan=3 bgcolor="#5F9EA0">Population Coverage with selected supertypes</th>
</tr>
<tr>
<th align="center" colspan=3>
<textarea name="coverage" rows="1" cols="8">
0 % </textarea>
</th>
</tr>
</table>
</form>
</BODY>
</HTML>

reche
05-30-2003, 08:05 AM
Dear Dave, thanks a lot for suggesting turning on error reporting in IE. Once, I do that I get a error in line 30 chanr 12 saying that object does not support this property or method.
This is the line and method and question:
calcArray.push( motif );
Any suggestion or way around to make this function to work in IE? Thanks for you help in advance.
javscript source is at:

http://mif.dfci.harvard.edu/temp_javas.html

reche
05-30-2003, 12:28 PM
Hi all, just in case someone is interested in my original post. it seems that IE does not support the push function?!! So i have changed the function that was giving me troubles;
calArray.push(motif);
by the following;
calArray[calArray.length]=motif;

and it works.
cheers