Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ColdFusion Logic

0 views
Skip to first unread message

Cotolay

unread,
Mar 16, 2005, 6:40:57 PM3/16/05
to
Hello I am new to scripting. I decided to learn CF. And i have been asked to
make a paint calculator, that calculates the amount of paint u need to use
based on the area ur gonna paint. Well i created a form where u can selct
diferent types of paints, and then when u select ur paint u enter the base and
the hight and a submit button to calculate it. Well, i have been having some
problems with the code, cuz when i select another painting category after
calculating the amount of paint, the form stays with the values. i need to make
them so that when i select another type, the form resets. Well if annyone can
help me, that would be great.

Thanks,
Coto

Here is the code:

<cfparam default="" name="URL.calculadora">
<cfparam default="" name="URL.area">
<cfparam default="" name="URL.tipo">
<cfparam default="" name="URL.ebanisteria">
<cfparam default="" name="URL.pintura">

<cfif URL.pintura EQ "acrilicamate">
<cfset rendimiento = 27>
<cfelseif URL.pintura EQ "semigloss">
<cfset rendimiento = 27>
<cfelseif URL.pintura EQ "economica">
<cfset rendimiento = 27>
<cfelseif URL.pintura EQ "supereconomica">
<cfset rendimiento = 27>
<cfelseif URL.pintura EQ "domatecho">
<cfset rendimiento = 6>
<cfelseif URL.pintura EQ "sav">
<cfset rendimiento = 7>
<cfelseif URL.pintura EQ "pastapetrea">
<cfset rendimiento = 5>
<cfelseif URL.pintura EQ "pastarelieve">
<cfset rendimiento = 6>
<cfelseif URL.pintura EQ "mantenimiento">
<cfset rendimiento = 33>
<cfelseif URL.pintura EQ "mantenimientoeconomico">
<cfset rendimiento = 33>
<cfelseif URL.pintura EQ "imprimaciones">
<cfset rendimiento = 27>
<cfelseif URL.pintura EQ "bnb">
<cfset rendimiento = 30>

<cfelseif URL.pintura EQ "barnizplastico">
<cfset rendimiento = 30>
<cfelseif URL.pintura EQ "sellador">
<cfset rendimiento = 33>
</cfif>
<cfif IsDefined("URL.Submit")>
<cfset multiplica = URL.base * URL.altura>
<cfset resultado = multiplica / rendimiento>
</cfif>

<html>
<head>
<title>Pinturas Domastur</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form action="<cfoutput>#CGI.SCRIPT_NAME#</cfoutput>" method="get"
name="calculadora" id="calculadora">
<table width="320" cellpadding="0" cellspacing="1">
<tr>
<td width="117" height="30" bgcolor="##CCCCCC">Area de Pintura :
</td>
<td width="198" height="30" bgcolor="##CCCCCC"><select name="area"
id="area" onChange="document.forms.calculadora.submit()">
<option value="su" selected>Seleccione Una</option>
<option value="arquitectonica"<cfif URL.area EQ "arquitectonica">
selected</cfif>>Arquitectonica</option>
<option value="ebanisteria"<cfif URL.area EQ "ebanisteria">
selected</cfif>>Ebanisteria</option>
</select>
</td>
</tr>
<tr>
<td height="30" bgcolor="##CCCCCC">Tipo de Pintura : </td>
<td height="30" bgcolor="##CCCCCC">
<cfif IsDefined ("URL.area")>
<cfif URL.area EQ "arquitectonica">
<select name="tipo" size="1" id="tipo"
onChange="document.forms.calculadora.submit()">
<option value="su" selected>Seleccione Una</option>
<option value="acrilica"<cfif URL.tipo EQ "acrilica">
selected</cfif>>Acrilica</option>
<option value="impermeabilizantes"<cfif URL.tipo EQ "impermeabilizantes">
selected</cfif>>Impermeabilizantes</option>
<option value="texturizados"<cfif URL.tipo EQ "texturizados">
selected</cfif>>Texturizados</option>
<option value="mantenimiento"<cfif URL.tipo EQ "mantenimiento">
selected</cfif>>Mantenimiento</option>
</select>
<cfelseif URL.area EQ "ebanisteria">
<select name="select" size="1" id="select2"
onChange="document.forms.calculadora.submit()">
<option value="su" selected>Seleccione Una</option>
<option value="barnices"<cfif URL.tipo EQ "barnices">
selected</cfif>>Barnices</option>
<option value="sellador"<cfif URL.tipo EQ "sellador">
selected</cfif>>Sellador</option>
</select>
</cfif>
</cfif>
</td>
</tr>
<tr>
<td height="30" bgcolor="##CCCCCC">Pintura :</td>
<td height="30" bgcolor="##CCCCCC">
<cfif IsDefined ("URL.tipo")>
<cfif URL.tipo EQ "acrilica">
<select name="pintura" id="pintura">
<option value="su" selected>Seleccione Una</option>
<option value="acrilicamate"<cfif URL.pintura EQ "acrilicamate">
selected</cfif>>Acrilica Mate</option>
<option value="semigloss"<cfif URL.pintura EQ "semigloss">
selected</cfif>>Semigloss</option>
<option value="economica">Econ&oacute;mica</option>
<option value="supereconomica">Super Econ&oacute;mica</option>
</select>
<cfelseif URL.tipo EQ "impermeabilizantes">
<select name="pintura" id="pintura">
<option value="su" selected>Seleccione Una</option>
<option value="domatecho"<cfif URL.pintura EQ "domatecho">
selected</cfif>>Domatecho</option>
<option value="sav"<cfif URL.pintura EQ "sav"> selected</cfif>>Sellador
alta viscosidad</option>
</select>
<cfelseif URL.tipo EQ "texturizados">
<select name="pintura" id="pintura">
<option value="su" selected>Seleccione Una</option>
<option value="pastapetrea">Pasta P&eacute;trea</option>
<option value="pastarelieve"<cfif URL.pintura EQ "pastarelieve">
selected</cfif>>Pasta Relieve</option>
</select>
<cfelseif URL.tipo EQ "mantenimiento">
<select name="pintura" id="pintura">
<option value="su" selected>Seleccione Una</option>
<option value="mantenimiento"<cfif URL.pintura EQ "mantenimiento">
selected</cfif>>Mantenimiento</option>
<option value="mantenimientoeconomico">Mantenimiento
Econ&oacute;mico</option>
<option value="imprimaciones"<cfif URL.pintura EQ "imprimaciones">
selected</cfif>>Imprimaciones Antioxidantes </option>
</select>
<cfelseif URL.tipo EQ "barnices">
<select name="pintura" id="pintura">
<option value="su" selected>Seleccione Una</option>
<option value="bnb"<cfif URL.pintura EQ "bnb"> selected</cfif>>Barniz
Natural con Brillo</option>
<option value="barnizplastico"<cfif URL.pintura EQ "barnizplastico">
selected</cfif>>Barniz Pl&aacute;stico</option>
</select>
<cfelseif URL.tipo EQ "sellador">
<select name="pintura" id="pintura">
<option value="sellador" selected<cfif URL.pintura EQ "sellador">
selected</cfif>>Sellador</option>
</select>
</cfif>
</cfif>
</td>
</tr>
<tr>
<td height="30" bgcolor="##CCCCCC">Tama&ntilde;o del area : </td>
<td height="30" bgcolor="##CCCCCC"><table width="198" height="70"
border="0" cellpadding="0" cellspacing="0">
<tr>
<td><p>Ancho : </p> </td>
<td valign="middle"><input name="base" type="text" id="base3"
value="<cfif IsDefined("URL.BASE")><cfoutput>#URL.base#</cfoutput></cfif>"
size="10" maxlength="10">
mts.</td>
</tr>
<tr>
<td>Altura : </td>
<td><input name="altura" type="text" id="altura24" value="<cfif
IsDefined("URL.BASE")><cfoutput>#URL.Altura#</cfoutput></cfif>" size="10"
maxlength="10">
mts</td>
</tr>
</table> </td>
</tr>
<tr>
<td height="30" bgcolor="##CCCCCC">&nbsp;</td>
<td height="30" bgcolor="##CCCCCC"><input type="submit" name="Submit"
value="Calcular"></td>
</tr>
<tr>
<td height="30" bgcolor="##CCCCCC">Resultado :</td>
<td height="30" bgcolor="##CCCCCC"><input name="resultado" type="text"
id="resultado" value="<cfif IsDefined ("URL.Submit")>
<cfoutput>#resultado#</cfoutput> </cfif>" size="10" maxlength="10">
gals. </td>
</tr>
</table>
</form>

jdeline

unread,
Mar 16, 2005, 7:17:04 PM3/16/05
to
Welcome to the world of scripting.

For starters, replace that initial CFIF / CFELSEIF piece of code with
CFSWITCH / CFCASE Check out
http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-c10.htm#wp1103819
for the detalis. Second, when copying code into a posting on these forums, use
the "Attach Code" button at the bottom of the screen. And indent, indent,
indent if you want people to read your code.

I'll try to address your other issues later today.

Cotolay

unread,
Mar 16, 2005, 8:15:23 PM3/16/05
to
Thanks Bro. I need to learn how to use those tags.
0 new messages