Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    script works in windows but not in mac.

    I have an order form script that is working wonderfully in windows, but isn´t totalling the price or sending the info by email correctly in Mac. Any ideas why this might be? Are there some tags not recognized in Mac? Thanks for any suggestions.

    Code:
    <script type="text/javascript">
    
    	var wineName = new Array('Verdejo','Shiraz','Merlot','Type1','Type2','Type3','Type4','Type5','Type6','Type7')
    
    	var winePrice = new Array('8.99','10.99','8.99','3.99','6.99','4.99','4.99','4.50','4.99','2.99')
    
    	function CalculateTotal(nForm){
    
    		var totalCost = 0;
    		var n = 0;
    		for (i=0; i<nForm.length; i++)
    			{
    			 if (nForm[i].type == 'text' && nForm[i].name != 'TOTAL' && nForm[i].name != 'company' && nForm[i].name != 'email')
    				{
    				 totalCost += nForm[i].value * winePrice[n++];
    				}
    			}
    		nForm['TOTAL'].value = totalCost.toFixed(2);
    	}
        
    	function sendMail(nForm,rForm){
    
    		var n = 0; 
    		var r = 0;
    		var isBody = "%0D%0AOur Wine Order:%0D%0A%0D%0A";
    		var recipient = "email@hotmail.com";
    		var isSubject = "Wine Order Submission";
    		for (i=0; i<nForm.length; i++)
    			{
    			 if (nForm[i].type == 'text' && nForm[i].name != 'TOTAL' && nForm[i].value != "" && nForm[i].name != 'company' && nForm[i].name != 'email')
    				{
    				 isBody += nForm[i].value +" "+ wineName[(n++)+(i-n-1)] +" @ $"+ winePrice[(r++)+(i-r-1)] + " each %0D%0A";
    				}
    			}
    		isBody += '%0D%0ATotal: $'+ nForm['TOTAL'].value;
    
    		isBody = nForm['company'].value + '%0D%0A' + isBody;
    	
    		isBody = nForm['email'].value + '%0D%0A' + isBody;
    
    		document.forms.Send.action = "mailto:"+recipient+"?subject="+isSubject+"&body="+isBody+"&nbsp";
    	}
    
    </script>
    </Head>
    
    <BODY BGCOLOR=#FFFFFF>
    
    <CENTER>
    <FORM name='wineOrder'>
    
    <FONT FACE="Arial, Verdana, Helvetica, MS Sans Serif" COLOR=#000088 SIZE=+2 CLASS="TitleText">
    <strong>Calculating Order Form Totals</strong>
    </FONT>
    <br><br>
    
    <TABLE BORDER = '1' cellspacing='0' cellpadding='5'>
    
    <TR>
    <TD colspan='3'>
    Company Name: <input type='text' size='30' name='company'>
    </TD>
    </TR>
    
    <TR>
    <TD colspan='3'>
    Email Contact: <input type='text' size='30' name='email'>
    </TD>
    </TR>
    
    
    <TR>
    <TD COLSPAN=3 align='center'><strong>Wine</strong></TD>
    </TR>
    
    <TR>
    <TD ALIGN="CENTER"><strong>Quantidad</strong></TD>
    <TD ALIGN="CENTER"><strong>DescripciÛn</strong></TD>
    <TD ALIGN="CENTER"><strong>Precio<BR>(each)</strong></TD>
    </TR>
    
    <TR>
    <TD ALIGN="CENTER"><INPUT TYPE=TEXT NAME="PROD_VD_8.99" SIZE=3 MAXLENGTH=3 onblur="CalculateTotal(this.form)"></TD><TD>Verdejo</TD><TD ALIGN="RIGHT">$8.99</TD>
    </TR>
    <TR><TD ALIGN="CENTER"><INPUT TYPE=TEXT NAME="PROD_SZ_10.99" SIZE=3 MAXLENGTH=3 onblur="CalculateTotal(this.form)"></TD><TD>Shiraz</TD><TD ALIGN="RIGHT">$10.99</TD>
    </TR>
    <TR><TD ALIGN="CENTER"><INPUT TYPE=TEXT NAME="PROD_MR_8.99" SIZE=3 MAXLENGTH=3 onblur="CalculateTotal(this.form)"></TD><TD>Merlot</TD><TD ALIGN="RIGHT">$8.99</TD>
    </TR>
    <TR><TD ALIGN="CENTER"><INPUT TYPE=TEXT NAME="PROD_T1_3.99" SIZE=3 MAXLENGTH=3 onblur="CalculateTotal(this.form)"></TD><TD>Type1</TD><TD ALIGN="RIGHT">$3.99</TD>
    </TR>
    <TR><TD ALIGN="CENTER"><INPUT TYPE=TEXT NAME="PROD_T2_6.99" SIZE=3 MAXLENGTH=3 onblur="CalculateTotal(this.form)"></TD><TD>Type2</TD><TD ALIGN="RIGHT">$6.99</TD>
    </TR>
    <TR><TD ALIGN="CENTER"><INPUT TYPE=TEXT NAME="PROD_T3_4.99" SIZE=3 MAXLENGTH=3 onblur="CalculateTotal(this.form)"></TD><TD>Type3</TD><TD ALIGN="RIGHT">$4.99</TD>
    </TR>
    <TR><TD ALIGN="CENTER"><INPUT TYPE=TEXT NAME="PROD_T4_4.99" SIZE=3 MAXLENGTH=3 onblur="CalculateTotal(this.form)"></TD><TD>Type4</TD><TD ALIGN="RIGHT">$4.99</TD>
    </TR>
    <TR><TD ALIGN="CENTER"><INPUT TYPE=TEXT NAME="PROD_T5_4.50" SIZE=3 MAXLENGTH=3 onblur="CalculateTotal(this.form)"></TD><TD>Type5</TD><TD ALIGN="RIGHT">$4.50</TD>
    </TR>
    <TR><TD ALIGN="CENTER"><INPUT TYPE=TEXT NAME="PROD_T6_4.99" SIZE=3 MAXLENGTH=3 onblur="CalculateTotal(this.form)"></TD><TD>Type6</TD><TD ALIGN="RIGHT">$4.99</TD>
    </TR>
    <TR><TD ALIGN="CENTER"><INPUT TYPE=TEXT NAME="PROD_T7_2.99" SIZE=3 MAXLENGTH=3 onblur="CalculateTotal(this.form)"></TD><TD>Type7</TD><TD ALIGN="RIGHT">$2.99</TD>
    <TR><TD><BR></TD><TD>TOTAL</TD><TD ALIGN="RIGHT">$<INPUT TYPE=TEXT NAME=TOTAL SIZE=10 readonly></TD>
    
    </TABLE>
    <INPUT TYPE=RESET VALUE="CLEAR FORM">
    </FORM>
    <Form name='Send'>
    <input type='submit' value='Submit Order' onclick="sendMail(document.wineOrder,document.custInfo)">
    </Form>
    </Center>

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The first question to ask is what browser are you using, and what version?

  • #3
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I´m using IE 5.2, but I also tried viewing it with Safari. Then I asked a few friends who also use Mac to try it from their computers and it doesn´t work well for them either, though I don´t know what version of IE they were using.

  • #4
    Regular Coder
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, first thing's first... it has nothing to do with being on a Mac. It has everything to do with the browser it's being viewed on.

    Secondly, I did some tests, and this script seems that it was ONLY programmed for IE/Win. That alone can cause all kinds of compatibility problems.

    This is a revised version that I tested in IE6/Win, Firefox, and Safari. It should also work in Opera, and any other modern browser. That said, IE/Mac is garbage. It ranks up there with Netscape 4.x and IE 5.x. It's nearly 6 years old, and I don't know anyone who even uses it anymore, with the exception of a few MacOS9 laggards. My professional opinion? Forget IE/Mac.

    Here's the revised code:
    Code:
    <html>
    <head>
    
    <title>Test Page</title>
    
    <script type="text/javascript">
    var wineName = new Array('Verdejo','Shiraz','Merlot','Type1','Type2','Type3','Type4','Type5','Type6','Type7');
    var winePrice = new Array('8.99','10.99','8.99','3.99','6.99','4.99','4.99','4.50','4.99','2.99');
    
    function CalculateTotal(nForm) {
    	var totalCost = 0;
    	var n = 0;
    
    	for (i=0; i<nForm.length; i++) {
    		if (nForm[i].type == 'text' && nForm[i].name != 'TOTAL' && nForm[i].name != 'company' && nForm[i].name != 'email') {
    			totalCost += nForm[i].value * winePrice[n++];
    		}
    	}
    
    	nForm['TOTAL'].value = totalCost.toFixed(2);
    }
    
    function sendMail(nForm,rForm) {
    	var n = 0; 
    	var r = 0;
    	var isBody = "%0D%0AOur Wine Order:%0D%0A%0D%0A";
    	var recipient = "email@hotmail.com";
    	var isSubject = "Wine Order Submission";
    
    	for (i=0; i<nForm.length; i++) {
    		if (nForm[i].type == 'text' && nForm[i].name != 'TOTAL' && nForm[i].value != "" && nForm[i].name != 'company' && nForm[i].name != 'email') {
    			isBody += nForm[i].value +" "+ wineName[(n++)+(i-n-1)] +" @ $"+ winePrice[(r++)+(i-r-1)] + " each %0D%0A";
    		}
    	}
    
    	isBody += '%0D%0ATotal: $'+ nForm['TOTAL'].value;
    	isBody = nForm['company'].value + '%0D%0A' + isBody;
    	isBody = nForm['email'].value + '%0D%0A' + isBody;
    
    	location.href = "mailto:"+recipient+"?subject="+isSubject+"&body="+isBody;
    }
    </script>
    </head>
    <body bgcolor="#FFFFFF">
    	<div align="center">
    		<form name="wineOrder" id="wineOrder" action="">
    			<h1>Calculating Order Form Totals</h1>
    
    			<table border="1" cellspacing="0" cellpadding="5">
    				<tr>
    					<td colspan="3">Company Name: <input type="text" size="30" name="company" /></td>
    				</tr>
    				<tr>
    					<td colspan="3">Email Contact: <input type='text' size='30' name='email' /></td>
    				</tr>
    				<tr>
    					<td colspan="3" align="center"><strong>Wine</strong></td>
    				</tr>
    				<tr>
    					<td align="center"><strong>Quantidad</strong></td>
    					<td align="center"><strong>Descripci&oacute;n</strong></td>
    					<td align="center"><strong>Precio<br />(each)</strong></td>
    				</tr>
    				<tr>
    					<td align="center"><input type="TEXT" name="PROD_VD_8.99" size="3" maxlength="3" onblur="CalculateTotal(this.form);" /></td>
    					<td>Verdejo</td>
    					<td align="right">$8.99</td>
    				</tr>
    				<tr>
    					<td align="center"><input type="TEXT" name="PROD_SZ_10.99" size="3" maxlength="3" onblur="CalculateTotal(this.form);" /></td>
    					<td>Shiraz</td>
    					<td align="right">$10.99</td>
    				</tr>
    				<tr>
    					<td align="center"><input type="TEXT" name="PROD_MR_8.99" size="3" maxlength="3" onblur="CalculateTotal(this.form);" /></td>
    					<td>Merlot</td>
    					<td align="right">$8.99</td>
    				</tr>
    				<tr>
    					<td align="center"><input type="TEXT" name="PROD_T1_3.99" size="3" maxlength="3" onblur="CalculateTotal(this.form);" /></td>
    					<td>Type1</td>
    					<td align="right">$3.99</td>
    				</tr>
    				<tr>
    					<td align="center"><input type="TEXT" name="PROD_T2_6.99" size="3" maxlength="3" onblur="CalculateTotal(this.form);" /></td>
    					<td>Type2</td>
    					<td align="right">$6.99</td>
    				</tr>
    				<tr>
    					<td align="center"><input type="TEXT" name="PROD_T3_4.99" size="3" maxlength="3" onblur="CalculateTotal(this.form);" /></td>
    					<td>Type3</td>
    					<td align="right">$4.99</td>
    				</tr>
    				<tr>
    					<td align="center"><input type="TEXT" name="PROD_T4_4.99" size="3" maxlength="3" onblur="CalculateTotal(this.form);" /></td>
    					<td>Type4</td>
    					<td align="right">$4.99</td>
    				</tr>
    				<tr>
    					<td align="center"><input type="TEXT" name="PROD_T5_4.50" size="3" maxlength="3" onblur="CalculateTotal(this.form);" /></td>
    					<td>Type5</td>
    					<td align="right">$4.50</td>
    				</tr>
    				<tr>
    					<td align="center"><input type="TEXT" name="PROD_T6_4.99" size="3" maxlength="3" onblur="CalculateTotal(this.form);" /></td>
    					<td>Type6</td>
    					<td align="right">$4.99</td>
    				</tr>
    				<tr>
    					<td align="center"><input type="TEXT" name="PROD_T7_2.99" size="3" maxlength="3" onblur="CalculateTotal(this.form);" /></td>
    					<td>Type7</td>
    					<td align="right">$2.99</td>
    				</tr>
    				<tr>
    					<td>&nbsp;</td>
    					<td>TOTAL</td>
    					<td align="right">$
    					<input type="TEXT" name="TOTAL" size="10" readonly="readonly" /></td>
    				</tr>
    			</table>
    			<input type="reset" value="CLEAR FORM" /><br /><br />
    			<input type="button" value='Submit Order' onclick="sendMail(document.wineOrder,document.custInfo);" />
    		</form>
    	</div>
    </body>
    </html>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •