Ask a Question related to Macromedia ColdFusion, Design and Development.
-
Cotolay #1
ColdFusion Logic
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ómica</option>
<option value="supereconomica">Super Econó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é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ó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á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ñ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"> </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>
Cotolay Guest
-
Separating Presentation from Logic in Coldfusion MX 7?
Hi, I was wondering, is there a good way to separate your presentation from the logic using Coldfusion? I have been reading about the PHP Smarty... -
Logic
I need some help. I have 2 loops. One to find a RadioButtonList in datagrid and second in Session("Answ"). I am trying to assing value from... -
CMS logic problem
Hi All Yet again, I know this is a try it yourself, but I just want to get your feedback/comments on this. I'm creating a CMS that will allow... -
Logic Error
Hi There I am developing a small Purchase Order application and have run into a small issue I have a two tables called PODetails and POHeader... -
logic help please
Hi, I need a sprite to check where its member's position is in a large nested list (which is a combination property and linear list). Here is the... -
jdeline #2
Re: ColdFusion Logic
Welcome to the world of scripting.
For starters, replace that initial CFIF / CFELSEIF piece of code with
CFSWITCH / CFCASE Check out
[url]http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-c10.htm#wp1103819[/url]
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.
jdeline Guest
-



Reply With Quote

