By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,649 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,649 IT Pros & Developers. It's quick & easy.

Returning checked checkbox values

P: 13
Greetings all in ASP land
I have overcome one obstacle that took me 2 weeks to overcome and I
did it!!!!!
I am so elated!! thank you to all who invested their time and energy towards helping me with my problems.

Now for my new little problem,I had a problem posting the values from checkbox fields to a database and thats the obstacle I overcame.
Now the second part is my new problem is that I want that the next time that page loads for that specific person or deal the previously checked checkboxes should appear,
meaning that if you previously checked some checkboxes the next time you select the name from a drop down list,the previously checked checkboxes should appear and the user can continue checking the rest.

my idea is just drawing the previously checked values from my table and displaying them as checked on my form.

Now for the cherry on top of the cake!!, Im not to sure on how im going to do this
or how it could be done.
If any one could please assist me in my feat to overcome this problem your help will be appreciated.

below is my code

code: (ASP)

<%@ Language = VBScript %>
<% Option Explicit %>

<!--#include virtual="/includes/adovbs.inc"-->
<!--#include virtual="/salesdesk/includes/Maint_ConnectADO.asp"-->
<!--#include virtual="/salesdesk/includes/access_control.asp"-->

<%
dim f, errStr, iDealID, iClientID, indDirectEdit, wfobject
call OpenConnection

f = request.querystring("f")
indDirectEdit = false

if len(f) < 1 then
f = request("f")
end if

if f = "e" or f = "d" then
if f = "e" then
iDealID = Cint(request("Deal_id"))
else
indDirectEdit = true
f = "e"
iDealID = CInt(request.querystring("ID"))
end if
if (request("submit1") = "True") or (indDirectEdit) then

strSQL = "SELECT ClientID from tblDeal where DealID = " & iDealID
set objRS = obj_Conn.execute(strSQL)
iClientID = CInt(objRS("ClientID"))
set objRS = nothing
end if
else
iClientID = CInt(request("company_id"))
end if

call WritePageTop

'Response.Cookies("MaintFacility")("LastFacility") = "DealEdit.asp?f=" & f
'Response.Cookies("MaintFacility").Expires = Date() + 7

if f="e" then
%>
Editing "Deals" List
<% else %>
Complete the workflow for the following:
<% end if %>
</div><br>
<table border="1" cellpadding="20" cellspacing="0" align="center" bgcolor="#B6E0B9" bordercolor="#006600">
<tr>
<td>
<%
errStr = ""

if request("submit2") = "True" then
' Submit button was clicked for the second time - second pass...
call Submit2
else
if (request("submit1") = "True") or (indDirectEdit) then
' Submit button was clicked for the first time - first pass...
call Submit1
else
' No submit button has been clicked yet.
' Display initial screen...
call NoSubmit
end if
end if

call Closeconnection
%>
</td></tr></table>
</body>
</html>
<%
'----------------------------------
sub Submit1
' Submit button was clicked the 1st time...
Dim strDealNumber, strDescription, strDealStatus, strDealValue, strQuotenumber
Dim strClientName, strRequestActive,checkbox

' If editing, read the contact detail
if f = "e" then
strSQL = "SELECT tblDeal.*, tblClient.ClientName " _
& "from tblDeal, tblClient " _
& "where DealID = " & iDealID _
& "and tblDeal.ClientID = tblClient.ClientID"
set objRS = obj_Conn.execute(strSQL)
iClientID = CInt(objRS("ClientID"))
strClientName = objRS("ClientName")
strDealNumber = objRS("DealNumber")
strDescription = objRS("Description")
strDealStatus = objRS("DealStatus")

set objRS = nothing
' Set indicator if request exists for contact that is not yet closed
strRequestActive = "AllClosed"
strSQL = "SELECT * from tblRepHelp where DealID = " & iDealID
set objRS = obj_Conn.execute(strSQL)
do until objRS.EOF or (strRequestActive = "OpenFound")
if objRS("status") = "Closed" then
else
strRequestActive = "OpenFound"
end if
objRS.MoveNext
loop
set objRS = nothing
else
strSQL = "SELECT ClientName " _
& "from tblClient " _
& "where ClientID = " & iClientID
set objRS = obj_Conn.execute(strSQL)
strClientName = objRS("ClientName")
set objRS = nothing
strDealStatus = "IN PROGRESS"
end if
%>
<table border="0" cellpadding="0" cellspacing="0">
<form method ='post' action='/salesdesk/workflowmaint.asp' name='theForm' onSubmit='return checkrequired(this)'>
<% if f = "e" then %>
<input type="hidden" name="Deal_id" value="<%= iDealID %>">
<% else %>
<input type="hidden" name="company_id" value="<%= iClientID %>">
<input type="Hidden" name="Deal_status" value="<%= strDealStatus %>">
<% end if %>
<input type="hidden" name="f" value="<%=f%>">
<input type="hidden" name="submit2" value="True"></td>
<tr>
<td colspan="4"><img src="/salesdesk/images/spacer.gif" width="1" height="5" border="0"></td>
</tr>

<tr>
<td><b><u>Client:</b></u></td>
<%'<td colspan="1" height="22" bgcolor="#CC99CC" style="border:solid 2 #006600;">&nbsp;<%= strClientName %></td>
<td><input type="text" colspan="1" height="22" bgcolor="#CC99CC" name= "strClientName" value=<%=strClientName%>></td>
</tr>

<tr>
<%'this is the new form im creating for workflow checkboxes%>
<td><div align="center">Completed maintennance with client? </div></td>


<div align="left">
<td><input type="checkbox" name="CompletedMaintAgree" value="yes">
</div></td></td>
</tr>
<tr>
<td><div align="center">Create a Client Folder on J:drive ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="CreatedFolder" value="yes">
<%if checkbox<> 0 then
response.write value="yes"
end if%>
</div></td>
</tr>

<tr>
<td><div align="center">Add Client on salesdesk ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="AddClienttoSalesdesk" value="yes">
</div></td>
</tr>

<tr>
<td><div align="center">Add Contact Person to Salesdesk ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="AddContacttoSalesdesk" value="yes">
</div></td>
</tr>

<tr>
<td><div align="center">Add Asset to Salesdesk ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="AddAssettoSalesdesk" value="yes">
</div></td>
</tr>

<tr>
<td><div align="center">Send FaxtoMail invite to Client? </div></td>
<td>
<div align="left">
<input type="checkbox" name="SendFaxtoMail" value="yes">
</div></td>
</tr>

<tr>
<td><div align="center">Ensure debit order form signed ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="DebitOrderSigned" value="yes">
</div></td>
</tr>

<tr>
<td><div align="center">Mail IT Polcies and procedures document ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="PoliciesandProcedures" value="yes">
</div></td>
</tr>

<tr>
<td><div align="center">Fax WOWConnect order form ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="FaxOrderForm" value="yes">
</div></td>
</tr>

<tr>
<td><div align="center">Mail welcome letter and presentation to Client ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="MailWelcomeLetter" value="yes">
</div></td>
</tr>

<tr>
<td><div align="center">Setup Client Troubleshooting Tools ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="SetupTools" value="yes">
</div></td>
</tr>

<tr>
<td><div align="center">Fix the IP of the server ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="SetupServerIP" value="yes">
</div></td>
</tr>

<tr>
<td><div align="center">Ensure that backups are OK ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="EnsureBackups" value="yes">
</div></td>
</tr>
<tr>
<td><div align="center">Setup VPN address correctly ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="SetupVPN" value="yes">
</div></td>
</tr>
<tr>
<td><div align="center">Train Branch Champion ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="BCTrain" value="yes">
</div></td>
</tr>
<tr>
<td><div align="center">Install VNC on all PC's ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="SetupVNC" value="yes">
</div></td>
</tr>
<tr>
<td><div align="center">Subscribe to Newsletter ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="SubscribetoNewsletter" value="yes">
</div></td>
</tr>
<tr>
<td><div align="center">Add details to SQL ledger ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="AddtoSQL" value="yes">
</div></td>
</tr>
<tr>
<td><div align="center">Perform PC Clean ups ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="PCCleanups" value="yes">
</div></td>
</tr>
<tr>
<td colspan="4"><img src="/salesdesk/images/spacer.gif" width="1" height="12" border="0"></td>
</tr>
<tr>
<td colspan="4"><img src="/salesdesk/images/spacer.gif" width="1" height="12" border="0"></td>
</tr>
<tr>
<td colspan="4"><img src="/salesdesk/images/spacer.gif" width="1" height="12" border="0"></td>
</tr>
<tr>
<td><B><U>Status:</B></U></td>
<% if (f = "e") then %>
<td><select name='Deal_status' size='1' style='width:130;'>
<option value='WON'
<% if strDealStatus = "WON" then %>
selected
<% end if %>
>IN PROGRESS</option>
<option value='IN PROGRESS'
<% if strDealStatus = "IN PROGRESS" then %>
selected
<% end if %>
style="color:#0000FF;">WON</option>
<% if (strRequestActive = "AllClosed") then %>
<option value='LOST'
<% if strDealStatus = "LOST" then %>
selected
<% end if %>
style="color:#FF0000;">LOST</option></td>
<% end if %>
<% else %>
<td height="22" bgcolor="#FFFFFF" style="border:solid 2 #006600;">&nbsp;<%= strDealStatus %></td>
<% end if %>
<td colspan="2"><img src="/salesdesk/images/spacer.gif" width="1" height="12" border="0"></td>
</tr>
<tr>
<td colspan="4"><img src="/salesdesk/images/spacer.gif" width="1" height="12" border="0"></td>
</tr>

<tr>
<td><img src="/salesdesk/images/spacer.gif" width="120" height="15" border="0"></td>
<td><img src="/salesdesk/images/spacer.gif" width="130" height="1" border="0"></td>
<td><img src="/salesdesk/images/spacer.gif" width="110" height="1" border="0"></td>
<td><img src="/salesdesk/images/spacer.gif" width="110" height="1" border="0"></td>
</tr>
<tr>
<td><img src="/salesdesk/images/spacer.gif" width="1" height="1" border="0"></td>
<td><a href="javascript:history.go(-1)">
<img src="/salesdesk/images/button_cancel.gif" alt="Cancel" width="80" height="20" border="0"></a></td>
<td colspan="2" align="right"><input type='Image' src='/salesdesk/images/button_save.gif'></td>
</tr>
</form>
</table>
<%
end sub
%>
<%
'----------------------------------
sub Submit2
' Submit button was clicked the 2nd time.
' Save the new or updated information

'if f="e" then
'strSQL = "Update tblDeal set DealNumber = '" & request.form("Deal_number") _
' & "', Description = '" & request.form("Description") _
' & "', DealStatus = '" & request.form("Deal_status") _
'& "' where DealID = " & request.form("Deal_id")
' else
strSQL = "INSERT INTO tblMaint "_
& "(ClientName,CompletedMaintAgree,CreatedFolder,Add ClienttoSalesdesk,AddContacttoSalesdesk,AddAssetto Salesdesk,SendFaxtoMail,DebitOrderSigned,Policiesa ndProcedures,FaxOrderForm,MailWelcomeLetter,SetupT ools,SetupServerIP,EnsureBackups,SetupVPN,BCTrain, SetupVNC,SubscribetoNewsletter,AddtoSQL,PCCleanups ) " _
& "values ('" & request.form("strClientName") & "', '" _
& request.form("CompletedMaintAgree") & "', '" _
& request.form("CreatedFolder") & "', '" _
& request.form("AddClienttoSalesdesk") & "', '" _
& request.form("AddContacttoSalesdesk") & "', '" _
& request.form("AddAssettoSalesdesk") & "', '" _
& request.form("SendFaxtoMail") & "', '" _
& request.form("DebitOrderSigned") & "', '" _
& request.form("PoliciesandProcedures") & "', '" _
& request.form("FaxOrderForm") & "', '" _
& request.form("MailWelcomeLetter") & "', '" _
& request.form("SetupTools") & "', '" _
& request.form("SetupServerIP") & "', '" _
& request.form("EnsureBackups") & "', '" _
& request.form("SetupVPN") & "', '" _
& request.form("BCTrain") & "', '" _
& request.form("SetupVNC") & "', '" _
& request.form("SubscribetoNewsletter") & "', '" _
& request.form("AddtoSQL") & "', '" _
& request.form("PCCleanups") & "')"

' Adding new Contact. Insert new record...
'strSQL = "INSERT INTO tblDeal " _
' & "(ClientID, DealNumber, Description, DealStatus) " _
' & "values (" & CInt(request.form("company_id")) & "', '" _
'& CInt(request.form("Deal_number")) & "', '" _
'& request.form("Description") & "', '" _
'& request.form("Deal_status") & "')" _
'end if
'on error resume next
obj_Conn.execute(strSQL)
%>
<div align="center" style="color:#006600; font-size:11pt; font-weight:600;">
Information has been saved.</div><br>
<div align="center">

<a href="/salesdesk/helplist.asp?f=e">
<img src="/salesdesk/images/view_helplist.gif" alt="Edit Deal" width="80" height="20" border="0"></a>&nbsp;&nbsp;
</div>
<%
end sub

'----------------------------------
sub NoSubmit
if f = "e" then
strSQL = "SELECT * from tblDeal, tblClient " _
& "where tblDeal.ClientID = tblClient.ClientID " _
& "and tblClient.ClientStatus = 'CURRENT' order by ClientName, DealNumber"
set objRS = obj_Conn.execute(strSQL)
if not objRS.eof then
%>
<table border="0" cellpadding="0" cellspacing="0">
<form method='post' action='/salesdesk/maint/workflowmaint.asp' name='theForm'>
<input type='hidden' name='f' value='<%= f %>'>
<input type='hidden' name='submit1' value='True'>
<br>
<tr>
<td colspan="2">Select the Deal to Edit:</td>
</tr>
<tr>
<td colspan="2"><img src="/salesdesk/images/spacer.gif" alt="" width="1" height="2" border="0"></td>
</tr>
<tr>
<td colspan="2"><select name='Deal_id' size='1' style='width:350;'>
<% do until objRS.eof %>
<option value='<%= objRS("DealID") %>'><%= objRS("ClientName") %> - <%= objRS("DealNumber") %></option>
<%
objRS.movenext
loop
%>
</select></td>
</tr>
<tr>
<td colspan="2"><img src="/salesdesk/images/spacer.gif" alt="" width="1" height="15" border="0"></td>
</tr>
<tr>
<td><a href="javascript:history.go(-1)">
<img src="/salesdesk/images/button_cancel.gif" alt="Cancel" width="80" height="20" border="0"></a></td>
<td align="right"><input type='Image' src='/salesdesk/images/button_edit.gif'></td>
</tr>
</form>
</table>
<% else
errStr = "You have not added any Deals to edit.<br>"
response.write errStr
end if

set objRS = nothing
else
strSQL = "SELECT * from tblClient " _
& "where tblClient.ClientStatus = 'CURRENT' order by ClientName"
set objRS = obj_Conn.execute(strSQL)
if not objRS.eof then
%>
<table border="0" cellpadding="0" cellspacing="0">
<form method='post' action='/salesdesk/workflowmaint.asp' name='theForm'>
<input type='hidden' name='f' value='<%= f %>'>
<input type='hidden' name='submit1' value='True'>
<input type='hidden' name='deal_id' value='<%= iDealID %>'>
<tr>
<td colspan="2">Workflow:</td>
</tr>
<tr>
<td colspan="2"><img src="/salesdesk/images/spacer.gif" alt="" width="1" height="2" border="0"></td>
</tr>
<tr>
<td colspan="2"><select name='company_id' size='1' style='width:350;'>
<% do until objRS.eof %>
<option value='<%= objRS("ClientID") %>'><%= objRS("ClientName") %></option>
<%
objRS.movenext
loop
%>
</select></td>
</tr>
<tr>
<td colspan="2"><img src="/salesdesk/images/spacer.gif" alt="" width="1" height="15" border="0"></td>
</tr>
<tr>
<td><a href="javascript:history.go(-1)">
<img src="/salesdesk/images/button_cancel.gif" alt="Cancel" width="80" height="20" border="0"></a></td>
<td align="right"><input type='Image' src='/salesdesk/images/workflown.gif'></td>
</tr>
</form>

</table>
<%
else
errStr = "You have not added any Companies to add an Deal to.<br>"
response.write errStr
end if
end if

set objRS = nothing
end sub

'----------------------------------
sub WritePageTop
%>
<html>
<head>

<SCRIPT LANGUAGE="JavaScript">
<!--

var Dealid = new Array();
var Dealno = new Array();

function loadDeals() {
<%
if (request("submit1") = "True") or (indDirectEdit) then
strSQL = "SELECT * FROM tblDeal where ClientID = " & iClientID
set objRS = obj_conn.execute(strSQL)
do until objRS.EOF
%>
Dealid[Dealid.length] = <%= objRS("DealID") %>;
Dealno[Dealno.length] = "<%= objRS("DealNumber") %>";
<%
objRS.movenext
loop
Set objRS = Nothing
end if
%>
}


function checkrequired(which) {
var pass=true;

if (pass) {
RequiredField = document.theForm.Deal_number.value;
EmptyField = true;
for (var i = 0; i < RequiredField.length; i++) {
if (RequiredField.substr(i,1) > " ") {
EmptyField = false;
break;
}
}
if (EmptyField) {
alert("Please Supply the Deal Name");
document.theForm.Deal_number.focus();
pass = false;
}
}

if (pass) {
if (document.theForm.Deal_number.value.indexOf("'") > -1) {
alert("The Deal Name\n"
+"contains an apostrophe ['] (single quote)\n"
+"which is an invalid character");
document.theForm.Deal_number.focus();
pass = false;
}
}

<% if f = "a" then %>
if (pass) {
var selectedDealno = document.theForm.Deal_number.value;
for (var i = 0; i < Dealno.length; i++) {
if (selectedDealno == Dealno[i]) {
alert("That Deal Name is already in Use\n"
+"for this Company. Please Change.");
document.theForm.Deal_number.focus();
pass = false;
break;
}
}
}
<% else %>
if (pass) {
var selectedDealno = document.theForm.Deal_number.value;
var selectedDealid = <%= iDealID %>;
for (var i = 0; i < Dealno.length; i++) {
if (selectedDealno == Dealno[i]) {
if (selectedDealid == Dealid[i]) {
} else {
alert("That Deal Name is already in Use\n"
+"for this Company. Please Change.");
document.theForm.Deal_number.focus();
pass = false;
break;
}
}
}
}
<% end if %>

if (pass) {
RequiredField = document.theForm.description.value;
EmptyField = true;
for (var i = 0; i < RequiredField.length; i++) {
if (RequiredField.substr(i,1) > " ") {
EmptyField = false;
break;
}
}
if (EmptyField) {
alert("Please Supply a Description of the Deal");
document.theForm.description.focus();
pass = false;
}
}

if (pass) {
if (document.theForm.description.value.indexOf("'") > -1) {
alert("The Deal Description\n"
+"contains an apostrophe ['] (single quote)\n"
+"which is an invalid character");
document.theForm.description.focus();
pass = false;
}
}

if (pass) {
if (document.theForm.deal_value.value.indexOf("'") > -1) {
alert("The Deal's Value\n"
+"contains an apostrophe ['] (single quote)\n"
+"which is an invalid character");
document.theForm.deal_value.focus();
pass = false;
}
}

if (pass) {
if (document.theForm.QuoteNumber.value.indexOf("'") > -1) {
alert("The QuoteNumber Details\n"
+"contain an apostrophe ['] (single quote)\n"
+"which is an invalid character");
document.theForm.QuoteNumber.focus();
pass = false;
}
}

return pass;
}

-->
</script>

<title>Help Desk - Edit/Add to the Contact List</title>

<style type="text/css">
<!--

body,td {
font-family:Verdana;
font-size:10pt;
}

body {
background-repeat : no-repeat;
background-image : url(/salesdesk/images/main_bg.jpg);
background-position : top;
background-color:#CFA0BA;
scrollbar-face-color : #CFA0BA;
scrollbar-arrow-color : #FFFFFF;
scrollbar-base-color : #CFA0BA;
}

td.Caption {
font-size:8pt;
}

td.List {
font-size:7pt;
}

td.ListRed {
font-size:7pt;
background-color:red;
color:#FFFFFF;
font-weight:600;
}

td.ListOrange {
font-size:7pt;
background-color:orange;
color:#000000;
font-weight:600;
}

td.ListGreen {
font-size:7pt;
background-color:green;
color:#FFFFFF;
font-weight:600;
}

td.Head {
font-size:8pt;
color:#333333;
}

a, a:link, a:visited, a:active {
color : #0000FF;
text-decoration : none;
font-weight:600;
}
a:hover {
color : #FF0000;
text-decoration : none;
font-weight:600;
}

-->
</style>

</head>
<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" onload="loadDeals()">
<br>

<div align="center" style="font-weight:600; font-size:12pt;">
<% end sub %>

<%
'Function AccessDateTime (dateandtime)
'Dim myDay
'Dim myMonth
'Dim myYear

'myDay = Day(dateandtime)
'If Len(myDay)=1 Then myDay="0" & myDay

'myMonth = Month(dateandtime)
'If Len(myMonth)=1 Then myMonth="0" & myMonth

'myYear = Year(dateandtime)

'AccessDateTime = myYear & "-" & myMonth & "-" & myDay & " " & Time()
'End Function

'sConnString="PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
'"Data Source=" & Server.MapPath("/salesdesk/database/Saleshelpdesk.mdb")
'Set connection = Server.CreateObject("ADODB.Connection")
'connection.Open(sConnString)


'Dim connection
'Dim SQL, sConnString
'the DateTime is the field in the DataBase
'SQL="INSERT INTO tblMaint(DateTime) VALUES (#" & AccessDateTime(NOW()) & "#)"
'connection.execute(SQL)

'Connection.Close
'Set Connection = Nothing
%>
Jul 10 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.