Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check box frustration 1

Status
Not open for further replies.

theogary

Programmer
Joined
Mar 3, 2003
Messages
99
Location
US
I have a dataentry form which fails because 2 fields are check boxes. If I change the input tag to e a "text" the update works fine. When the field is a checkbox I get the error "Error resolving parameter E.HOME_FORFIET_1" aka the checkbox. Do check boxes only wotk with boolean columns. My column in a CHAR(1). The form reads the checkbox field fine, it places the check in the box when home_forfiet field = 'Y' like it should but is I update any column and click submit I get the above error.

see code below

Please Help



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<Script language='javascript'>
function vforfiet(name,row)
{ alert('checked'+row);
if (document.scores[name].checked == true){
document.scores[name].value = 'Y';
h=eval("document.scores.e_home_forfiet_" + row);
h.value = 0;
v=eval("document.scores.e_visitor_forfiet_" + row);
v.value = 0;
box = eval("document.scores.e_home_forfiet_" + row);
box.checked = false;
box.value = 'N';
}
}
function hforfiet(name,row)
{ alert('checked'+row);
if (document.scores[name].checked == true){
document.scores[name].value = 'Y';
h=eval("document.scores.e_home_forfiet_" + row);
h.value = 0;
v=eval("document.scores.e_visitor_forfiet_" + row);
v.value = 0;
box = eval("document.scores.e_visitor_forfiet_" + row);
box.checked = false;
box.value = 'N';
}
}
</script>
</head>

<body>
<STYLE>
td {font-family:Arial, Helvetica, sans-serif; font-size:12px;}
</STYLE>

<cfif isDefined("form.submit")>
<cfoutput>
</cfoutput>
<cfloop from="1" to="#form.numrecords#" index="i">
<cfif (Evaluate("form.e_home_score_" & i) is NOT "#Evaluate("form.o_home_score_" & i)#") or
(Evaluate("form.e_visitor_score_" & i) is NOT "#Evaluate("form.o_visitor_score_" & i)#") or
(Evaluate("form.e_home_forfiet_" & i) is NOT "#Evaluate("form.o_home_forfiet_" & i)#") or
(Evaluate("form.e_visitor_forfiet_" & i) is NOT "#Evaluate("form.o_visitor_forfiet_" & i)#")>
<cfquery name="updatequery" datasource="baseball" username = "baseball" password = "Password">
UPDATE schedule
SET home_score = '#Evaluate("form.e_home_score_" & i)#',
visitor_score = '#Evaluate("form.e_visitor_score_" & i)#',
visitor_forfiet = '#Evaluate("form.e_visitor_forfiet_" & i)#',
home_forfiet = '#Evaluate("form.e_home_forfiet_" & i)#'
WHERE ID = '#Evaluate("form.id_" & i)#'
</cfquery>
</cfif>
</cfloop>
<!--- </cfif> --->
</cfif>

<cfquery name="games" datasource="baseball" username = "baseball" password =

"Password">
SELECT league,game_date from schedule group by
league,game_date order by league,game_date
</cfquery>

<cfif isDefined("form.league")>

<cfquery name="myquery" datasource="baseball" username = "baseball" password =

"Password">
SELECT upper(game_date) game_date,upper(game_day) game_day,game_time,upper(location)

location,upper(home) home,
upper(visitor) visitor,upper(field) field,

league,id,home_score,visitor_score,home_forfiet,visitor_forfiet from schedule where league =

'#form.league#' and game_date = '#form.game_date#' order by game_date
</cfquery>

<cfelse>
<cfquery name="myquery" datasource="baseball" username = "baseball" password =

"Password">
SELECT upper(game_date) game_date,upper(game_day) game_day,game_time,upper(location)

location,upper(home) home,
upper(visitor) visitor,upper(field) field,

league,id,home_forfiet,visitor_forfiet,home_score,visitor_score from schedule where visitor=

'x' order by game_date
</cfquery>

</cfif>

<cfset tempVar = myquery.recordcount>
<cfoutput>
<!--- <input type="hidden" name="numrecords" value="#myquery.recordcount#"> --->
</cfoutput>

<CFSET TotalRows = myquery.RecordCount>
<!--- <input type="TEXT" name="id_#myquery.currentrow#" value="#myquery.id#"> --->
<table width="700" border="1" cellspacing="0" cellpadding="2">

<cfform method="POST" action="#CGI.script_name#" name="teams">
<tr><td colspan="7" class="tda">League
<cfif PARAMETEREXISTS(form.league)>
<!--- <cfoutput> #form.game_date# </cfoutput> --->
<CF_TwoSelectsRelated
Query = "games"
Name1 = "league"
Name2 = "game_date"
Display1 = "league"
Display2 = "game_date"
value1 = "league"
value2 = "game_date"
Default1="#form.league#"
Default2="#form.game_date#"
WIDTH="300px"
WIDTH2="200px"
HTMLBETWEEN ="Game Date "
FormName = "teams"
message1 = "asfafaf"
message2 = "adsfasdfasd"
>
<cfelse>
<CF_TwoSelectsRelated
Query = "games"
Name1 = "league"
Name2 = "game_date"
Display1 = "league"
Display2 = "game_date"
value1 = "league"
value2 = "game_date"
WIDTH="300px"
WIDTH2="200px"
HTMLBETWEEN ="Game Date "
FormName = "teams"
emptytext1 = "(Pick A League)"
emptytext2 = "(Pick A Game Date)"
message1 = "asfafaf"
message2 = "adsfasdfasd" >
</cfif>
<!--- ONCHANGE="Submit!" --->
<input type="submit" value="Go" >
</cfform>
</td></tr>
<cfform method="POST" action="#CGI.script_name#" name="scores">
<cfoutput>
<input type="hidden" name="numrecords" value="#myquery.recordcount#">
<cfif PARAMETEREXISTS(form.game_date)>
<input type="hidden" name = "game_date" value="#form.game_date#">
</cfif>
<cfif PARAMETEREXISTS(form.league)>
<input type="hidden" name = "league" value="#form.league#">
</cfif>
</cfoutput>
<TR>
<td height="15" align="left">DATE </td>
<td height="15" align="right">HOME FORFIET </td>
<td height="15" align="left">HOME</td>
<td height="15" align="left">RUNS </td>
<td height="15" align="left">VISITOR </td>
<td height="15" align="left">RUNS</td>
<td height="15" align="right">VISITOR FORFIET</td>


</TR>
<CFLOOP QUERY="myquery" StartRow=1 ENDROW="#TotalRows#">
<CFOUTPUT>
<input type="hidden" name="id_#myquery.currentrow#" value="#myquery.id#">
<input type="hidden" name="o_home_forfiet_#myquery.currentrow#" value="#myquery.home_forfiet#"

>
<input type="hidden" name="o_visitor_forfiet_#myquery.currentrow#"

value="#myquery.visitor_forfiet#" >
<input type="hidden" name="o_home_score_#myquery.currentrow#" value="#myquery.home_score#"

size="3">
<input type="hidden" name="o_visitor_score_#myquery.currentrow#" value="#myquery.visitor_score#"

size="3">
<tr>
<td width="100">#dateFormat(game_date, "mmm-dd-yyyy")#</td>
<td><input type="checkbox" name="e_home_forfiet_#myquery.currentrow#"

value="#myquery.home_forfiet#"
<cfif "#myquery.home_forfiet#" EQ "Y"> Checked </cfif>

onClick="hforfiet('e_home_forfiet_#myquery.currentrow#','#myquery.currentrow#')" ></td>
<td width="200">#home#</td>
<td><input type="text" name="e_home_score_#myquery.currentrow#" value="#myquery.home_score#"

size="3"></td>
<td width="200">#visitor#</td>
<td><input type="text" name="e_visitor_score_#myquery.currentrow#"

value="#myquery.visitor_score#" size="3"></td>
<td><input type="checkbox" name="e_visitor_forfiet_#myquery.currentrow#"

value="#myquery.visitor_forfiet#"
<cfif "#myquery.visitor_forfiet#" EQ "Y"> Checked </cfif>

onClick="vforfiet('e_visitor_forfiet_#myquery.currentrow#','#myquery.currentrow#')" > </td>
</tr>
</CFOUTPUT>
</CFLOOP>
</table>
<input type="submit" name="submit" value="submit">
</cfform>


</body>
</html>
 
Your checkboxes are not going to exist on your action page unless they are checked in the form. You're trying to do an update using the value of the checkboxes, but if they aren't checked, they don't exist. That's why you're getting the error.

Off the top of my head, I can think of two ways to handle this:
1) use cfparam before your update statement to assign a value to the two check boxes if they are not checked.
2) use <cfif IsDefined("Form.CheckboxName")> statements in your update statement to determine if you should/shouldn't try to update the checkbox's fields in the database.



Hope This Helps!

Ecobb

&quot;My work is a game, a very serious game.&quot; - M.C. Escher
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top