
January 8th, 2006, 12:30 PM
|
|
Registered User
|
|
Join Date: Jan 2006
Posts: 3
Time spent in forums: 33 m 24 sec
Reputation Power: 0
|
|
Perform OnClick action multiple times
I'm trying to fill and update a table by means of a checkbox. The following code works fine when the check box is clicked once (the record in the column BasicLine is changed from 0 to 1) when the checkbox is clicked again (I want it to change from 1 to 0) it does not execute the update. If I refresh the page before I click it a second time it works fine (but I don't want to refresh...  ). Does anyone know how to solve this??
Code:
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/kv_conn.asp" -->
<%
var BasicLine = Server.CreateObject("ADODB.Recordset");
BasicLine.ActiveConnection = MM_kv_conn_STRING;
BasicLine.Source = "SELECT * FROM dbo.ProdLine";
BasicLine.CursorType = 0;
BasicLine.CursorLocation = 2;
BasicLine.LockType = 1;
BasicLine.Open();
var BasicLine_numRows = 0;
%>
<%
var up_BasicLine = Server.CreateObject("ADODB.Command");
up_BasicLine.ActiveConnection = MM_kv_conn_STRING;
up_BasicLine.CommandText = "if (select BasicLine from prodline) = 1 UPDATE prodline SET BasicLine = 0 else update prodline set BasicLine = 1";
up_BasicLine.CommandType = 1;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<input <%=(((BasicLine.Fields.Item("BasicLine").Value) == 1)?"checked":"")%> name="BasicLine" type="checkbox" onClick="<% up_BasicLine.Execute() %>"value="">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
</body>
</html>
<%
BasicLine.Close();
%>
|