p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 1.0 and 1.1 Basics (http://p2p.wrox.com/forumdisplay.php?f=60)
-   -   Calculation using if...then...else statement (http://p2p.wrox.com/showthread.php?t=54726)

oliver February 28th, 2007 08:51 PM

Calculation using if...then...else statement
 
Hi,

I'm Trying to find out if ASP calculation can be used with if...then...else statement. Did few changes but when trying to open the file it would not let me. Trying to do is these "if (T) > (S-T) then (T) else (S-T)". T = transportation & S = shipping charge. I do not have experienced of this but I want to learn more as I go along with it.

Current Cart Value: $9.00
Shipping Charge: $
Total: $
Shipping Method Transportation Shipping Charge
UPS Ground USA $5.00 $5.81
UPS 3 Day Select $10.00 $11.62
UPS 2nd Day Air $25.00 $28.24
UPS 2nd Day Air AM $25.00 $28.24
UPS Next Day Air $55.00 $59.68


<html>
    <head>
        <Title><%=sWebSiteName%> - Shipping Calculator</title>





    </head>
    <body class="siteNav3TD">
        Shipping Calculator
        <table width="450" cellspacing="5" cellpadding="0" border="0">
            <tr>
                <td width="425">
                    <form name="frmShip" method="post" action="<%=sNonSecurePath%>shipcalculator.asp?Cart Id=<%=sCartId%>" onSubmit="return ZipCode_validate('<%=bUseDestZone%>');">
                        <table width=425>
                            <tr>
                                <td width=125> Zipcode: </td>
                                <td width=300><input tabindex="1" type="text" size="15" maxlength="15" name="zipcode" value="<%=sZipCode%>" Class="Content"></td>
                            </tr>
                            <%If bUseDestZone Then%>
                                <tr>
                                    <td width=125> City: </td>
                                    <td width=300><input tabindex="2" type="text" size="15" maxlength="40" name="City" value="<%=sCity%>" Class="Content">(Only for United States)</td>
                                </tr>
                                <tr>
                                    <td width=125> State: </td>
                                    <td width=300><input tabindex="3" type="text" size="15" maxlength="25" name="State" value="<%=sState%>" Class="Content">(Only for United States)</td>
                                </tr>
                                <%If Not rsCountries.Eof Then%>
                                <tr>
                                    <td width=125>Country:</td>
                                    <td width=300>

                                        <select name="COUNTRY" size="1" tabindex="4" Class="Content"><%
                                            Do While Not rsCountries.Eof
                                                If rsCountries("COUNTRY_NAME") = sCountry Then
                                                    Response.Write "<option value='" & rsCountries("COUNTRY_NAME") & "' selected>" & rsCountries("COUNTRY_NAME") & "</option>"
                                                Elseif rsCountries("COUNTRY_NAME")="UNITED STATES" And sCountry="" Then
                                                    Response.Write "<option value='" & rsCountries("COUNTRY_NAME") & "' selected>" & rsCountries("COUNTRY_NAME") & "</option>"
                                                Else
                                                    Response.Write "<option value='" & rsCountries("COUNTRY_NAME") & "'>" & rsCountries("COUNTRY_NAME") & "</option>"
                                                End if
                                                rsCountries.Movenext
                                            Loop%>
                                        </select>

                                    </td>
                                </tr>
                                <%End if
                            End if%>
                            <tr>
                                 <td width=125 >Address type:</td>
                                 <td>

                                    <select name="RESI" tabindex="5" Class="Content">
                                         <option value = "0">Please select address type</option>
                                         <option value = "F" <%If sAddressinfo = "F" Then%>selected<%End If%>>Business</option>
                                         <option value = "T" <%If sAddressinfo = "T" Then%>selected<%End If%>>Residential</option>
                                    </select>

                                 </td>
                            </tr>
                            <%If objShoppingCart.IsCODEnabled(sConnectionString,sCa rtId) Then%>
                                <tr>
                                 <td width=125 >COD Fee:</td>
                                 <td><INPUT type="checkbox" name="ISCOD" tabindex="6" <% If bIsCOD Then %> checked <%End if%>>
                                 </td>
                                </tr>
                            <%End if%>
                            <tr><td>Â </td><td> <a tabindex="7" href="#" onClick="ZipCode_validate('<%=bUseDestZone%>');ret urn false;"> <img src="images/go.gif" border="0"></a></td></tr>
                        </table>
                        <br>To calculate your shipping charge, enter the ZipCode. Then, select the carrier of your choice.
                    </form>
                </td>
            </tr>
        </table>

        <%If (Trim(sCountry) <> "" OR Trim(sZipcode) <> "") Then
            If Not rsDeliveryMethod.Eof Then
                If rsDeliveryMethod("AMOUNT") > 0 OR rsDeliveryMethod("FREE_SHIPPING") = "T" Then
                    If sZipCode = "" Then%>
                        <br>
                            <b>Shipping methods available for the country "<%=Trim(sCountry)%>".</b>
                        <br>
                    <%Else%>
                        <br>
                            <b>Shipping methods available for the zipcode "<%=Trim(sZipCode)%>".</b>
                    <%End if%>

                    <form name="frmCost">
                        <table border="0" cellspacing="0" width="600" cellpadding="5">
                            <tr>
                                <td colspan="4">
                                    <table border="0" cellspacing="0" width="450" cellpadding="5">
                                        <tr>
                                            <td>Current Cart Value: </td>
                                            <td><%= sCurrSymbol & Formatnumber(sCartTotal,2)%><%If bAddCurrExists Then%> (<%=sAdditionalCurrencySymbol%><%=Formatnumber(sCa rtTotalInAddCurr,2)%>)<%End If%></td>
                                        </tr>
                                        <tr>
                                            <td>Shipping Charge:</td>
                                            <td><%=sCurrSymbol%><input type="text" name="shipprice" value=<%=FormatNumber(rsDeliveryMethod("AMOUNT"),2 )%> size="10" readonly onfocus = "this.blur()" class=content><%If bAddCurrExists Then%> <%=sAdditionalCurrencySymbol%>Â Â <input type="text" name="shipprice_add_curr" value=<%=FormatNumber(rsDeliveryMethod("ADD_CURR_A MOUNT"),2)%> size="10" readonly onfocus = "this.blur()" class=content><%End If%></td>
                                        </tr>
                                        <tr>
                                            <td>Total:</td>
                                            <td><%=sCurrSymbol%><input type="text" name="total" size="10" value=<%=FormatNumber((cdbl(rsDeliveryMethod("AMOU NT"))) * (cdbl(sCartTotal),2))%> readonly onfocus = "this.blur()" class=content><%If bAddCurrExists Then%> <%=sAdditionalCurrencySymbol%>Â Â <input type="text" name="total_add_curr" size="10" value=<%=FormatNumber((cdbl(rsDeliveryMethod("ADD_ CURR_AMOUNT")) * cdbl(sCartTotalInAddCurr)),2)%> readonly onfocus = "this.blur()" class=content><%End If%></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td>Shipping Method</td>
                                <td>Transportation</td>
                                <%If bIsCOD Then%>
                                <td><span class="ContboldRd">COD Fee</span></span></td>
                                <%End if%>
                                <td>Shipping Charge</td>
                            </tr>
                            <%iIndex = 1
                            Do While Not rsDeliveryMethod.Eof%>
                                <tr>
                                    <td>
                                        <input type="radio" name="radsel" value="<%=FormatNumber(rsDeliveryMethod("AMOUNT"), 2,,,0)%>*<%=FormatNumber(rsDeliveryMethod("ADD_CUR R_AMOUNT"),2,,,0)%>" <%If iIndex=1 Then%>Checked<%End If %> onClick="ShipCharge_Calculate(<%=Application("loca le")%>);">
                                        <%=rsDeliveryMethod("Deliv_DESC")%></td>
                                    <td><span class="Contsmall"><%=sCurrSymbol & FormatNumber(rsDeliverymethod ("TRANSPORTATION"))%><%If bAddCurrExists Then%> (<%=sAdditionalCurrencySymbol & FormatNumber(rsDeliverymethod("ADD_CURR_TRANSPORTA TION"),2)%>)<%end if%></span></td>
                                    <%If bIsCOD Then%>
                                        <td><span class="Contsmall"><%=sCurrSymbol & FormatNumber(rsDeliverymethod ("CODFEE"))%><%If bAddCurrExists Then%> (<%=sAdditionalCurrencySymbol & FormatNumber(rsDeliverymethod("ADD_CURR_CODFEE"),2 )%>)<%end if%></span></td>
                                    <%End if%>
                                    <td><%=sCurrSymbol & FormatNumber(rsDeliveryMethod("AMOUNT"),2)%> <%If bAddCurr < bAddCurr-(rsDeliveryMethod("AMOUNT"),2) Then%> (<%=sAdditionalCurrencySymbol & FormatNumber(rsDeliverymethod("ADD_CURR_AMOUNT"),2 )%>)<% ELSE (bAddCurr-(rsDeliveryMethod("AMOUNT"),2)) = sAdditionalCurrencySymbol & FormatNumber(rsDeliverymethod("ADD_CURR_AMOUNT"),2 )%> <%end if%></td>
                                </tr>
                                <%rsDeliveryMethod.MoveNext
                                iIndex = iIndex + 1
                            Loop%>
                            <tr><td colspan="4">Note: The charges listed are estimates. Actual shipping charges will be calculated during the checkout process.</td></tr>
                        </table>
                    <Script language=javascript >
                        ShipCharge_Calculate(<%=Application("locale")%>)
                    </script>
                <%Else%>
                    No shipping method is available for the selected criteria.
                <%End If
            Else%>
                No shipping method is available for the selected criteria.
            <%End If
        End If%>
        </form>
        <br><br>
        <a href="#" onClick="window.close();return false;"><img src="images/close.gif" border="0" tabindex="8" alt="Close"></a>
    </BODY>

    <script language="javascript">
        setTitleForImages();
        if((navigator.userAgent.toUpperCase().indexOf("MAC ") != -1) && (navigator.userAgent.toUpperCase().indexOf("GECKO" ) == -1))
        {
            setHrefForLinks();
        }
    </script>
</HTML>



dparsons February 28th, 2007 09:07 PM

This is the wrong forum, you should be posting in the classic forum. Likewise posting that much code isn't bound to get you much help as none of use are going to copy it, paste it, and see what happens. Paste your problemmatic code that is pertienent to your question.

To answer your question though, if you do something like

If (2 + 3) < (2 + 4) then

End if

Yes that will work.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from planoie's profile^^
^^Modified text taken from gbianchi profile^^
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========

click March 7th, 2007 07:29 PM

if (T) > (S-T) then (T) else (S-T)".
T = transportation & S = shipping charge.

sub doIt()
  dim myReturnValue as integer
  myReturnValue = getHigher(shippingCost,Transportation)
end sub

private function getHigher(s as integer,t as integer) as integer
  if t > (s - t) then
     return t
  else
     return s - t
  end if
end function





All times are GMT -4. The time now is 06:05 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.