Arielladog
06-14-2001, 05:05 AM
Hey dfred and welcome to the forum,
Can you show us some code of the outputted ColdFusion (HTML code) and maybe the ColdFusion itself?
aDog :cool:
dfred
06-15-2001, 03:07 PM
here is my problem...
first, I am a Cold Fusion user:
I am dynamically populating text fields based on a selection from a selection box. there can be either one or two text fields depending on what is selected from the box. I pass that through a loop to add corresponding data fields to the text fields. The problem is validating those fields for empty values. for one text field it is easier, but if there are two text fields, the fields have the same name and the validation will only validate the first one and ignore the second one. When the values are passed to an action page, if there are two values, they are passed in a comma delimited list. Can anyone help me validate my form?
DAN
dfred
06-15-2001, 06:50 PM
ok here is the code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<CFQUERY NAME="condition_code" datasource="#session.dbase#" username="#session.uname#" password="#session.pword#">
SELECT condition_code
FROM condition_codes
</cfquery>
<html>
<head>
<title>Receive Kit</title>
<script language="JavaScript1.2" src="MBValidate.js" type="text/javascript"></script>
<cfoutput>
<SCRIPT LANGUAGE="JavaScript">
function ref()
{
document.receive_kit.action='#CGI.SCRIPT_NAME#?get_comps=Yes';
document.receive_kit.submit();
}
</SCRIPT>
</cfoutput>
<script language="JavaScript">
function ShowCalendar(FormName, FieldName)
{
window.open("CFDateSelectPopupWindow.cfm?FormName=" + FormName + "&FieldName=" + FieldName, "CalendarWindow", "width=200,height=220");
}
</script>
<script language="JavaScript">
function validate() {
if (document.receive_kit.location.value == "") {
alert("please fill in a location")
return false;
}
return true;
}
</script>
</head>
<body>
<link rel="stylesheet" href="../lib/d_style.css">
<cfform NAME="receive_kit" action="receivekit.cfm" method="POST" onsubmit="return validate()">
<!--- onsubmit="return check_empty();" --->
<CF_EmbedFields>
<cfparam name="getComps" default="">
<cfparam name="form.kit_number" default="">
<cfparam name="DATE_DISCOVERED" default="">
<!--- <cfparam name="DATE_DISCOVERED1" default="">
<cfparam name="DATE_DISCOVERED2" default=""> --->
<cfquery name = "getLoc" DATASOURCE="#SESSION.DBASE#" username="#SESSION.uname#" PASSWORD="#SESSION.PWORD#">
Select l.location_name, l.loc_code
FROM locations l,
unit_infos u
WHERE l.loc_code = u.loc_Code and
u.primary_loc = 'T'
</cfquery>
<cfoutput>
<font color = "blue"><b>#getLoc.location_name#</b>
<b> - </b>
<b>Receipt Kit </b></font>
</cfoutput>
<cfif #session.MBSuperUser# IS "T"><!--- If a superuser... --->
<font color = "silver"><b><i>Super-User Mode</i></b></font>
<cfelseif session.verify IS "yes">
<font color = "silver"><b><i>Verification Mode</i></b></font>
<cfelse>
<font color = "silver"><b><i>Initial Data Entry Mode</i></b></font>
</cfif><br>
<!--- <cf_embedfields> --->
<!--- Weapon Code: <cfoutput>#form.MAJ_ASM_NAME#</cfoutput>
Part Number: <cfoutput>#form.MAJ_ASM_PART_NBR#</cfoutput>
Serial Numbers: <cfoutput>#form.MAJ_ASM_SERIAL_NBR# </cfoutput> --->
<br>
<table>
<tr>
<td>
<cfquery name="kit" datasource="#session.dbase#" username="#session.uname#" password="#session.pword#">
SELECT KIT_NUMBER
FROM KIT_SPECS
</cfquery>
<b>Kit Number:</b><br>
<cfselect name="kit_number" onChange="ref()" size="1" >
<CFOUTPUT QUERY="kit">
<option
value="#kit.kit_number#"
<CFIF IsDefined("FORM.kit_number") AND kit.kit_number IS FORM.kit_number>
SELECTED
</CFIF>
>
#kit.kit_number#</option>
</CFOUTPUT>
</cfselect>
<br>
<CFIF IsDefined("getComps")>
<!--- <CFOUTPUT>
#FORM.kit_number#
</CFOUTPUT> --->
<cfquery name="comps" datasource="#session.dbase#" username="#session.uname#" password="#session.pword#">
select a.default_part_number
from comp_specs a, kit_comps b, kit_specs c
where b.kit_number = c.kit_number and
a.comp_noun_code = b.comp_noun_code and
a.comp_item_assoc = b.comp_item_assoc and
b.kit_number = '#FORM.kit_number#'
</cfquery>
<CFLOOP query="comps">
<table><tr><td>
<!--- <input type="text" NAME="components" VALUE=<cfoutput>#kit.kit_number#</cfoutput> --->
Part Number: <input type="text" NAME="comps" VALUE=<cfoutput>#default_part_number#</cfoutput>
onclick="validate(comps,'<cfoutput>#default_part_number#</cfoutput>')"></INPUT>
Serials: <INPUT TYPE="TEXT" NAME="Serial_number" SIZE=12></INPUT>
<INPUT TYPE="hidden" NAME="Serial_number_required" value="serial number required"></INPUT>
Condition Code: <!--- <CFSELECT QUERY="condition_code" NAME="condition_code" size="1" value="condition_code" display="condition_code">
<option value=""></option>
</CFSELECT> --->
<cfquery name="condition_code" datasource="#session.dbase#" username="#session.uname#" password="#session.pword#">
SELECT *
FROM condition_codes
<!--- WHERE condition_code = 'A' or 'D' --->
</cfquery>
<select name="condition_code" size="1">
<option default=""></option>
<cfoutput query="condition_code">
<option values="#condition_code.condition_code#">#condition_code#</option>
</cfoutput>
</select>
Fill Date:
<cf_dm_calendar form="receive_kit" name="DATE_DISCOVERED#comps.currentrow#" Calendardir="/Calendardir" value="#variables.DATE_DISCOVERED#" FORMAT="MMM-YYYY">
</td>
</tr>
</table>
</cfloop>
</cfif>
there is more on the page, but this is where I am having the problem. Also with this page, if you look at the code, once you select the kit_number from the select box, it populates the part_number text boxes (either one or two from the query). Now if someone picked the wrong kit_number and selects a new one, that new value is appended to the last value and bombs out the whole process. So I have multiple problems which no one has been able to solve. Validation and single values from the select box. I hope this code helps.
Thanks
DAN
vBulletin® v3.6.4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.