<%
Dim CN, myDSN, sql_update, arr_ids
myDSN="Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\GMISDATA.mdb"
set CN=server.createobject("ADODB.Connection")
CN.Open myDSN
'Let us fill our arr_ids with the ids - split on comma space because when we
have multiple form
' inputs withthe same name and value comes through as a comma-space
delimited string.
arr_ids = Split(Request.Form("ExpIntID"),", ")
'now loop through each id, build the sql, and execute the sql
Dim id
For each id in arr_ids
sql_update = "UPDATE tblGMISExpenditures_Quarter set IsChecked = "
If request.form("chk_Unlock_" & id) <> "" Then
sql_update = sql_update & "True"
else
sql_update = sql_update & "False"
End If
'And finally the where porttion
'sql_update = sql_update & " WHERE ExpIntID = " & id
'response.write sql_update & "<br>"
CN.execute sql_update
next
Response.write "Bye" & "<br>"
CN.close
Set CN = Nothing
%>
I appreciate any help.
Why are these lines commented out?
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
<%
Dim CN, myDSN, sql_update, arr_ids
myDSN="Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\GMISDATA.mdb"
set CN=server.createobject("ADODB.Connection")
CN.Open myDSN
'Let us fill our arr_ids with the ids - split on comma space because when we
'have multiple form
' inputs withthe same name and value comes through as a comma-space
'delimited string.
Response.Write "Request.Form(""ExpIntID"") contains " & _
Request.Form("ExpIntID") & "<BR>"
arr_ids = Split(Request.Form("ExpIntID"),", ")
'now loop through each id, build the sql, and execute the sql
Dim id
For each id in arr_ids
sql_update = "UPDATE tblGMISExpenditures_Quarter set IsChecked = "
response.write sql_update & "<br>"
If request.form("chk_Unlock_" & id) <> "" Then
sql_update = sql_update & "True"
else
sql_update = sql_update & "False"
End If
Response.Write "Request.Form(""chk_Unlock_""" & id & ") contains " & _
Request.Form("chk_Unlock_" & id) & "<BR>"
response.write sql_update & "<br>"
'And finally the where porttion
sql_update = sql_update & " WHERE ExpIntID = " & id
response.write sql_update & "<br>"
CN.execute sql_update
next
Response.write "Bye" & "<br>"
CN.close
Set CN = Nothing
%>
Bob Barrows
The sql statement is not "showing anything" because the loop never runs.
<%
'The following line is to prevent this page coming from history.
'We need a new page fro the server each time so that all the
'session variables are reset
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
%>
<% Response.Buffer = True %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title>List All Subgrants For Unlocking or Unverifying</title>
<%
'We need this to determine grantid. When coming into FDSReport.asp from
ListSubgrants.asp
'the first time, we get grantid from the query string. Otherwise
'we use the session grantid through out this application.
session("sess_FiscalFirst")="Y"
%>
<SCRIPT LANGUAGE="VBScript">
sub btn_LogOut_OnClick()
dim asnwer
answer=msgbox("Are you sure you want to exit?.",vbYesNo,"Warning")
if answer=vbyes then
window.location.href = "http://localhost/gwis"
end if
end sub
sub btn_Save_OnClick()
dim asnwer
answer=msgbox("Are you sure you want to save your
changes?",vbYesNo,"Warning")
if answer=vbyes then
window.location.href = "http://localhost/gwis/processundo.asp"
end if
end sub
</SCRIPT>
</HEAD>
<%
myDSN="Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\GMISDATA.mdb"
set CN=server.createobject("ADODB.Connection")
CN.Open myDSN
'sRS stands for recordset that corresponds to all active subgrants
set sRS=server.createobject("ADODB.Recordset")
'set sRS1 = server.createobject("ADODB.Recordset")
sRS.ActiveConnection = CN
'sRS1.ActiveConnection = CN
SQL = "SELECT * from qryUnlockAndUnverify"
sRS.Open SQL
'SQL1 = "SELECT count(*) from GMISExpenseCombo1"
' sRS1.Open SQL1
%>
<div ALIGN="CENTER">
<big><big><font COLOR="navy">On-Line Grant Reporting System</font></big></big>
<H4>
<font COLOR="red">Listing Of Active Subgrants For Unlocking or
Unverifying</font>
</H4>
</div>
<input type="button" value="Log Out" name="btn_LogOut" >
<input type="submit" value="Save" name="btn_Save">
<form method = "POST" NAME="frmUnDo ACTION = "processundo.asp">
<div ALIGN="CENTER">
<table border=1 width=90% height=1>
<tr>
<th>Key</th>
<th>SubgrantID</th>
<th>Title</th>
<th>Unlock</th>
<th>Unverify</th>
</tr>
<%
'Queue up to the top record of the recordset
if not sRS.eof then sRS.MoveFirst
'Make a temporary variable for user id
Dim t_id
do until sRS.eof
t_id = sRS("ExpIntID")
Key = sRS("SubgrantIntId")
Subgrant = sRS("ComboID")
Title = sRS("Title")
'l_IsChecked = sRS("IsChecked")
'l_IsVerified = sRS("IsVerified")
%>
<tr>
<td align="center">
<input type="hidden" name="ExpIntID" value="<%=t_id%>">
<div style="cursor:hand"><p align="left"
OnClick="location.href='mainreportagain1.asp?GrantID=<%Response.Write Key%>'">
<u><font color="#0000FF">
<%Response.Write Key%></font></u></div></td>
<% 'this writes out the key%>
</td>
<td align='center'>
<font color="#000000">
<%=Subgrant%>
<td align='center'>
<font color="#000000">
<%=Title%>
</td>
<td align='center'>
<font color="#000000">
<input type="checkbox" name="chk_Unlock_<%=t_id%>" value="ON" <%if
sRS("IsChecked") = True then response.write " checked" else Response.write "
unchecked"%>>
</td>
</td>
<td align='center'>
<font color="#000000">
<input type="checkbox" name="chk_UnVerify_<%=t_id%>" value="ON" <%if
sRS("IsVerified")= true then response.write" checked" else Response.write "
unchecked"%>>
</td>
</tr>
<%
sRs.MoveNext
loop
sRS.Close
Set sRS = Nothing
%>
</DIV>
</table>
</form>
</BODY>
</HTML>
Jack wrote:
> Well Bob, I spend quite a while to go through my code to find why the
> request.form("ExpIntID") value is not showing up. However, I could
> not find the reason even after trying to find from different angle. I
> am attaching the asp code associated with the form. If you can figure
> it out, please let me know. Thanks.
> CODE:
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
<HTML>
<BODY>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<title>List All Subgrants For Unlocking or Unverifying</title>
<SCRIPT LANGUAGE="VBScript">
sub btn_LogOut_OnClick()
dim asnwer
answer=msgbox("Are you sure you want to exit?.",vbYesNo,"Warning")
if answer=vbyes then
window.location.href = "http://localhost/gwis"
end if
end sub
sub btn_Save_OnClick()
dim asnwer
answer=msgbox("Are you sure you want to save your
changes?",vbYesNo,"Warning")
if answer=vbyes then
window.location.href = "http://localhost/gwis/processundo.asp"
end if
end sub
</SCRIPT>
</HEAD>
<div ALIGN="CENTER">
<big><big><font COLOR="navy">On-Line Grant Reporting System</font></big></big>
<H4>
<font COLOR="red">Listing Of Active Subgrants For Unlocking or
Unverifying</font>
</H4>
</div>
<input type="button" value="Log Out" name="btn_LogOut" >
<input type="submit" value="Save" name="btn_Save">
<form method = "POST" NAME="frmUnDo ACTION = "processundo.asp">
<div ALIGN="CENTER">
<table border=1 width=90% height=1>
<tr>
<th>Key</th>
<th>SubgrantID</th>
<th>Title</th>
<th>Unlock</th>
<th>Unverify</th>
</tr>
<tr>
<td align="center">
<input type="hidden" name="ExpIntID" value="3">
<div style="cursor:hand"><p align="left"
OnClick="location.href='mainreportagain1.asp?GrantID=5428'">
<u><font color="#0000FF">
5428</font></u></div></td>
</td>
<td align='center'>
<font color="#000000">
03-A50-81628
<td align='center'>
<font color="#000000">
FY04 -FY05- FY06 Juvenile Accountability Admin.
</td>
<td align='center'>
<font color="#000000">
<input type="checkbox" name="chk_Unlock_3" value="ON" checked>
</td>
</td>
<td align='center'>
<font color="#000000">
<input type="checkbox" name="chk_UnVerify_3" value="ON" checked>
</td>
</tr>
<tr>
<td align="center">
<input type="hidden" name="ExpIntID" value="4">
<div style="cursor:hand"><p align="left"
OnClick="location.href='mainreportagain1.asp?GrantID=5558'">
<u><font color="#0000FF">
5558</font></u></div></td>
</td>
<td align='center'>
<font color="#000000">
04-W02-81686
<td align='center'>
<font color="#000000">
Comprehensive Criminal Justice Training
</td>
<td align='center'>
<font color="#000000">
<input type="checkbox" name="chk_Unlock_4" value="ON" checked>
</td>
</td>
<td align='center'>
<font color="#000000">
<input type="checkbox" name="chk_UnVerify_4" value="ON" checked>
</td>
</tr>
Hope this helps. Regards.
By setting the window.location.href property, you are failing to submit the
form.
Instead of navigating to the processundo page, you need to call the form's
submit() method. Give your form element an id and do:
document.getElementById("formid").submit()
Also, this is malformed html (no end quote after frmUnDo):
<form method = "POST" NAME="frmUnDo ACTION = "processundo.asp">
Bob Barrows
Actually, even this is not necessary. I just realized that btn_Save is an
input of type="submit", so all you have to do is set the event's returnvalue
to false to prevent a form submission.
if answer=vbno then
event.returnvalue = false
end if
Bob Barrows
--