/    Sign up×
Community /Pin to ProfileBookmark

What could cause this?

I had a quick questions what would cause a disabled check box to still update the database field? I thought if it was disabled it didnt look at the field.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@KorNov 05.2006 — If it is disabled, any form's control will NOT be sent allong with it's value to the DB. Can we see your code?
Copy linkTweet thisAlerts:
@landslideauthorNov 05.2006 — here is my code. I cut out repeated parts because it was too long.

[CODE]<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../../../Connections/lvcc.asp" -->
<%
// *** Edit Operations: declare variables

// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
if (Request.QueryString) {
MM_editAction += "?" + Server.HTMLEncode(Request.QueryString);
}

// boolean to abort record edit
var MM_abortEdit = false;

// query string to execute
var MM_editQuery = "";
%>
<%
// *** Update Record: set variables

if (String(Request("MM_update")) == "form1" &&
String(Request("MM_recordId")) != "undefined") {

var MM_editConnection = MM_lvcc_STRING;
var MM_editTable = "tblJanuary";
var MM_editColumn = "SSN";
var MM_recordId = "" + Request.Form("MM_recordId") + "";
var MM_editRedirectUrl = "januaryconfirm.asp";
var MM_fieldsStr = "1ST|value|2ND|value|3RD|value|4TH|value|5TH|value|8TH|value|9TH|value|10TH|value|11TH|value|12TH|value|15TH|value|16TH|value|17TH|value|18TH|value|19TH|value|22ND|value|23RD|value|24TH|value|25TH|value|26TH|value|29TH|value|30TH|value|31ST|value|name|value|last|value|seid|value|ssn|value|team|value|hiddenField6|value";
var MM_columnsStr = "Jan1|',none,''|Jan2|',none,''|Jan3|',none,''|Jan4|',none,''|Jan5|',none,''|Jan8|',none,''|Jan9|',none,''|Jan10|',none,''|Jan11|',none,''|Jan12|',none,''|Jan15|',none,''|Jan16|',none,''|Jan17|',none,''|Jan18|',none,''|Jan19|',none,''|Jan22|',none,''|Jan23|',none,''|Jan24|',none,''|Jan25|',none,''|Jan26|',none,''|Jan29|',none,''|Jan30|',none,''|Jan31|',none,''|Firstname|',none,''|Lastname|',none,''|SEID|',none,''|[Last Four]|',none,''|ORGCODE|',none,''|Timestamp1|',none,''";

// create the MM_fields and MM_columns arrays
var MM_fields = MM_fieldsStr.split("|");
var MM_columns = MM_columnsStr.split("|");

// set the form values
for (var i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = String(Request.Form(MM_fields[i]));
}

// append the query string to the redirect URL
if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString;
}
}
%>
<%
// *** Update Record: construct a sql update statement and execute it

if (String(Request("MM_update")) != "undefined" &&
String(Request("MM_recordId")) != "undefined") {

// create the sql update statement
MM_editQuery = "update " + MM_editTable + " set ";
for (var i=0; i+1 < MM_fields.length; i+=2) {
var formVal = MM_fields[i+1];
var MM_typesArray = MM_columns[i+1].split(",");
var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
if (formVal == "" || formVal == "undefined") {
formVal = emptyVal;
} else {
if (altVal != "") {
formVal = altVal;
} else if (delim == "'") { // escape quotes
formVal = "'" + formVal.replace(/'/g,"''") + "'";
} else {
formVal = delim + formVal + delim;
}
}
MM_editQuery += ((i != 0) ? "," : "") + MM_columns[i] + " = " + formVal;
}
MM_editQuery += " where " + MM_editColumn + " = " + MM_recordId;

if (!MM_abortEdit) {
// execute the update
var MM_editCmd = Server.CreateObject('ADODB.Command');
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();

if (MM_editRedirectUrl) {
Response.Redirect(MM_editRedirectUrl);
}
}

}
%>
<%
var now = new Date();
var Recordset1__MMColParam = "1";
if (String(Session("MM_Username")) != "undefined" &&
String(Session("MM_Username")) != "") {
Recordset1__MMColParam = String(Session("MM_Username"));
}
%>
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = MM_lvcc_STRING;
Recordset1.Source = "SELECT SEID, LASTNAME, FIRSTNAME, FOURDIGITS, ORGCode FROM tblTollFreeEmployees WHERE SEID = '"+ Recordset1__MMColParam.replace(/'/g, "''") + "'";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
%>
<%
var Recordset2__MMColParam = "1";
if (String(Session("MM_Username")) != "undefined" &&
String(Session("MM_Username")) != "") {
Recordset2__MMColParam = String(Session("MM_Username"));
}
%>
<%
var Recordset2 = Server.CreateObject("ADODB.Recordset");
Recordset2.ActiveConnection = MM_lvcc_STRING;
Recordset2.Source = "SELECT * FROM tblJanuary WHERE SEID = '"+ Recordset2__MMColParam.replace(/'/g, "''") + "'";
Recordset2.CursorType = 0;
Recordset2.CursorLocation = 2;
Recordset2.LockType = 1;
Recordset2.Open();
var Recordset2_numRows = 0;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
<!--


function disableCheckBox() {
var obj=document.forms["form1"];
for (i=0;i<obj.length;i++) {
with (obj[i]) {
if (type=='checkbox' && checked) {
disabled=true;
}
}
}
}
//-->
</script>
<style type="text/css">
<!--
.style1 {font-size: 24px}
.style5 {
color: #FF0000;
font-weight: bold;
}
.style10 {font-size: 16px; font-weight: bold; }
body {
background-color: #FFFFCC;
}
.style11 {font-size: 16px}
.style12 {color: #FF0000}
-->
</style>
</head>

<body onload="disableCheckBox()">
<form ACTION="<%=MM_editAction%>" METHOD="POST" id="form1" name="form1">
<table width="721" border="1" align="center" cellpadding="1" cellspacing="0" bordercolor="#000000" bgcolor="#009933">
<tr>
<td colspan="7"><div align="center" class="style1">January</div></td>
</tr>
<tr>
<td colspan="7"><span class="style11">First Name <span class="style5"><%=(Recordset1.Fields.Item("FIRSTNAME").Value)%></span>Last Name <span class="style5"><%=(Recordset1.Fields.Item("LASTNAME").Value)%></span> SEID&nbsp; <span class="style5"><%=(Recordset1.Fields.Item("SEID").Value)%></span>&nbsp; SSN <span class="style5"><%=(Recordset1.Fields.Item("FOURDIGITS").Value)%></span>&nbsp; Team <span class="style5"><%=(Recordset1.Fields.Item("ORGCode").Value)%></span></span></td>
</tr>
<tr>
<td width="84"><div align="center" class="style10">SUNDAY</div></td>
<td width="91"><div align="center" class="style10">MONDAY</div></td>
<td width="97"><div align="center" class="style10">TUESDAY</div></td>
<td width="110"><div align="center" class="style10">WEDNESDAY</div></td>
<td width="107"><div align="center" class="style10">THURSDAY</div></td>
<td width="98"><div align="center" class="style10">FRIDAY</div></td>
<td width="96"><div align="center" class="style10">SATURDAY</div></td>
</tr>
<tr>
<td><div align="center"><span class="style1"></span>&nbsp; </div></td>
<td><div align="center" class="style1"><strong>&nbsp;&nbsp;1
<input name="1ST" type="checkbox" id="1ST" value="R" <%=(((Recordset2.Fields.Item("Jan1").Value) == "R" || Recordset2.Fields.Item("Jan1").Value == "A" || Recordset2.Fields.Item("Jan1").Value == "2")?"checked="checked"":"")%>/>
<span class="style12"><%=(Recordset2.Fields.Item("Jan1").Value)%></span></strong></div></td>
<td><div align="center" class="style1"><strong>&nbsp; 2
<input <%=(((Recordset2.Fields.Item("Jan2").Value) == "R")?"checked="checked"":"")%> name="2ND" type="checkbox" id="2ND" value="R" />
<span class="style12"><%=(Recordset2.Fields.Item("Jan2").Value)%></span> </strong></div></td>
<span class="style12"><%=(Recordset2.Fields.Item("Jan30").Value)%></span></strong></div></td>
<td><div align="center" class="style1"><strong>31
<input <%=(((Recordset2.Fields.Item("Jan31").Value) == "R")?"checked="checked"":"")%> name="31ST" type="checkbox" id="31ST" value="R" />
<span class="style12"><%=(Recordset2.Fields.Item("Jan31").Value)%></span></strong></div></td>
<td><div align="center"><span class="style1"></span>&nbsp; </div></td>
<td><div align="center" class="style1"><strong>
<input name="Submit" type="submit" value="Submit" />
</strong></div></td>
<td><div align="center"><span class="style1"></span>&nbsp; </div></td>
</tr>
</table>
<p>
<input name="name" type="hidden" id="name" value="<%=(Recordset1.Fields.Item("FIRSTNAME").Value)%>" />
<input name="last" type="hidden" id="last" value="<%=(Recordset1.Fields.Item("LASTNAME").Value)%>" />
<input name="seid" type="hidden" id="seid" value="<%=(Recordset1.Fields.Item("SEID").Value)%>" />
<input name="ssn" type="hidden" id="ssn" value="<%=(Recordset1.Fields.Item("FOURDIGITS").Value)%>" />
<input name="team" type="hidden" id="team" value="<%=(Recordset1.Fields.Item("ORGCode").Value)%>" />
<input name="hiddenField6" type="hidden" value="<%=new Date(now)%>" />
</p>
<input type="hidden" name="MM_update" value="form1">
<input type="hidden" name="MM_recordId" value="<%= Recordset2.Fields.Item("SSN").Value %>">
</form>
</body>
</html>
<%
Recordset1.Close();
%>
<%
Recordset2.Close();
%>[/CODE]
Copy linkTweet thisAlerts:
@landslideauthorNov 06.2006 — Any idea's
×

Success!

Help @landslide spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...