Click to See Complete Forum and Search --> : Works in Konqueror, IE not mozilla, netscape


CA_randy
12-22-2003, 11:57 PM
I have a simple page w/ java script. I am converting from VBscripting to make more accessible from alternate browsers. When I compare to other pages w/ scripts nothing looks different to me. It would be best to fix this before I put any more time into this page. I would appreciate anyone who could help.

Here is page:
<HTML>

<HEAD>
<TITLE>The Simple Metric Converter-*2</TITLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
function Convert2mm()
{
offsetdeduct = Offset_array.value;
if (Offset_array.value==98.1)
{
hoffsetdeduct = 70
}
else
{
hoffsetdeduct = Offset_array.value
}
InchesWidth = txtInchesWidth.value;
InchesHeight = txtInchesHeight.value;
mmWidth = eval(InchesWidth *25.4 - offsetdeduct);
mmHeight = eval(InchesHeight *25.4 - hoffsetdeduct);
mmWidth2 = Math.round(mmWidth);
mmHeight2 = Math.round(mmHeight);
mmsize.value=("A PVC window with a "+InchesWidth+" inches width and a "+InchesHeight+" inches height has an mm OSM of "+mmWidth2 + " mm Wide x " + mmHeight2+" mm High" );
txtmmwidth.value =(mmWidth2);
txtmmheight.value =(mmHeight2);


}
// -->
</SCRIPT>
</HEAD>

<BODY>
<H1>PVC only!</H1>
<P>Select the size given, enter the size in inches, and click on the "Convert" button to calculate.</P>
<P>Please note: only OSM and RO sizes will work for MC</P>
<select Name="Offset_array" size "1">
<option value="0" selected>OSM</option>
<option value="20" >RO</option>
<option value="98" >2"Bmld 4 sides</option>
<option value="98.1" >2"Bmld w/ sill</option>
<!-- <option value="54" >1 1/4"Bmld</option> -->
<option value="54" >J-Trim Bmld</option>
</select>



<left><PRE><H3>Inches</h3><INPUT NAME="txtInchesWidth" SIZE=5 value="0" > Width<br> x <br><INPUT NAME="txtInchesHeight" SIZE=5 value="0" > Height</PRE></left>
<P><left><INPUT TYPE="BUTTON" NAME="cmdConvert" onclick="Convert2mm()" VALUE="Convert"></left>
<!--<left><H4>MM OSM of frame is:</h4><textarea NAME="mmsize" rows=4 cols=20></textarea></left></p>-->
<P><left><PRE><H4>MM OSM of frame</h4><textarea NAME="txtmmwidth" rows=2 cols=10></textarea> Width<P> x <P><textarea NAME="txtmmheight" rows=2 cols=10></textarea> Height </PRE></left></p>

<HR>
<p>1/8" = .125 <br>
3/8" = .375 <br>
5/8" = .625 <br>
7/8" = .875 <br>

</P>
<HR>
<left><H4>MM OSM of frame is:</h4><textarea NAME="mmsize" rows=4 cols=50></textarea></left></p>

</BODY>

</HTML>

THANKS!!!!
Randy

Pittimann
12-23-2003, 03:21 AM
Hi!

You are using formfields for your stuff, but you are lacking the <form>...</form> tag. If you add the opening <form name="myForm"> (just an example) tag before the first formfield and the closing </form> after the last one and use "document.myForm." in your function, it should work...


function Convert2mm()
{
offsetdeduct = document.myForm.Offset_array.value;
if (document.myForm.Offset_array.value==98.1)
{
hoffsetdeduct = 70
}
else
{
hoffsetdeduct = document.myForm.Offset_array.value
}
InchesWidth = document.myForm.txtInchesWidth.value;
InchesHeight = document.myForm.txtInchesHeight.value;
mmWidth = eval(InchesWidth *25.4 - offsetdeduct);
mmHeight = eval(InchesHeight *25.4 - hoffsetdeduct);
mmWidth2 = Math.round(mmWidth);
mmHeight2 = Math.round(mmHeight);
mmsize.value=("A PVC window with a "+InchesWidth+" inches width and a "+InchesHeight+" inches height has an mm OSM of "+mmWidth2 + " mm Wide x " + mmHeight2+" mm High" );
document.myForm.txtmmwidth.value =(mmWidth2);
document.myForm.txtmmheight.value =(mmHeight2);
}

Cheers - Pit

ray326
12-23-2003, 11:52 AM
99% of the time when Javascript works on IE but not on NS it's because the Javascript is incorrect. And in most cases the errors are incorrect references to elements in the DOM. The elements of a form are part of the form and the form is part of the document so fField.value is not correct. The correct syntax is document.formName.fField.value.

CA_randy
12-23-2003, 01:25 PM
THANK you SOOOO much!!

Randy