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_ConnectAD O.asp"-->
<!--#include virtual="/salesdesk/includes/access_control. asp"-->
<%
dim f, errStr, iDealID, iClientID, indDirectEdit, wfobject
call OpenConnection
f = request.queryst ring("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("D eal_id"))
else
indDirectEdit = true
f = "e"
iDealID = CInt(request.qu erystring("ID") )
end if
if (request("submi t1") = "True") or (indDirectEdit) then
strSQL = "SELECT ClientID from tblDeal where DealID = " & iDealID
set objRS = obj_Conn.execut e(strSQL)
iClientID = CInt(objRS("Cli entID"))
set objRS = nothing
end if
else
iClientID = CInt(request("c ompany_id"))
end if
call WritePageTop
'Response.Cooki es("MaintFacili ty")("LastFacil ity") = "DealEdit.asp?f =" & f
'Response.Cooki es("MaintFacili ty").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="#B6E0B 9" bordercolor="#0 06600">
<tr>
<td>
<%
errStr = ""
if request("submit 2") = "True" then
' Submit button was clicked for the second time - second pass...
call Submit2
else
if (request("submi t1") = "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, strRequestActiv e,checkbox
' If editing, read the contact detail
if f = "e" then
strSQL = "SELECT tblDeal.*, tblClient.Clien tName " _
& "from tblDeal, tblClient " _
& "where DealID = " & iDealID _
& "and tblDeal.ClientI D = tblClient.Clien tID"
set objRS = obj_Conn.execut e(strSQL)
iClientID = CInt(objRS("Cli entID"))
strClientName = objRS("ClientNa me")
strDealNumber = objRS("DealNumb er")
strDescription = objRS("Descript ion")
strDealStatus = objRS("DealStat us")
set objRS = nothing
' Set indicator if request exists for contact that is not yet closed
strRequestActiv e = "AllClosed"
strSQL = "SELECT * from tblRepHelp where DealID = " & iDealID
set objRS = obj_Conn.execut e(strSQL)
do until objRS.EOF or (strRequestActi ve = "OpenFound" )
if objRS("status") = "Closed" then
else
strRequestActiv e = "OpenFound"
end if
objRS.MoveNext
loop
set objRS = nothing
else
strSQL = "SELECT ClientName " _
& "from tblClient " _
& "where ClientID = " & iClientID
set objRS = obj_Conn.execut e(strSQL)
strClientName = objRS("ClientNa me")
set objRS = nothing
strDealStatus = "IN PROGRESS"
end if
%>
<table border="0" cellpadding="0" cellspacing="0" >
<form method ='post' action='/salesdesk/workflowmaint.a sp' name='theForm' onSubmit='retur n checkrequired(t his)'>
<% if f = "e" then %>
<input type="hidden" name="Deal_id" value="<%= iDealID %>">
<% else %>
<input type="hidden" name="company_i d" value="<%= iClientID %>">
<input type="Hidden" name="Deal_stat us" value="<%= strDealStatus %>">
<% end if %>
<input type="hidden" name="f" value="<%=f%>">
<input type="hidden" name="submit2" value="True"></td>
<tr>
<td colspan="4"><im g src="/salesdesk/images/spacer.gif" width="1" height="5" border="0"></td>
</tr>
<tr>
<td><b><u>Clien t:</b></u></td>
<%'<td colspan="1" height="22" bgcolor="#CC99C C" style="border:s olid 2 #006600;">  ;<%= strClientName %></td>
<td><input type="text" colspan="1" height="22" bgcolor="#CC99C C" name= "strClientN ame" value=<%=strCli entName%>></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="Completed MaintAgree" 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="CreatedFo lder" 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="AddClient toSalesdesk" 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="AddContac ttoSalesdesk" value="yes">
</div></td>
</tr>
<tr>
<td><div align="center"> Add Asset to Salesdesk ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="AddAssett oSalesdesk" 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="SendFaxto Mail" 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="DebitOrde rSigned" 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="Policiesa ndProcedures" value="yes">
</div></td>
</tr>
<tr>
<td><div align="center"> Fax WOWConnect order form ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="FaxOrderF orm" 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="MailWelco meLetter" value="yes">
</div></td>
</tr>
<tr>
<td><div align="center"> Setup Client Troubleshooting Tools ? </div></td>
<td>
<div align="left">
<input type="checkbox" name="SetupTool s" 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="SetupServ erIP" 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="EnsureBac kups" 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="Subscribe toNewsletter" 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="PCCleanup s" value="yes">
</div></td>
</tr>
<tr>
<td colspan="4"><im g src="/salesdesk/images/spacer.gif" width="1" height="12" border="0"></td>
</tr>
<tr>
<td colspan="4"><im g src="/salesdesk/images/spacer.gif" width="1" height="12" border="0"></td>
</tr>
<tr>
<td colspan="4"><im g src="/salesdesk/images/spacer.gif" width="1" height="12" border="0"></td>
</tr>
<tr>
<td><B><U>Statu s:</B></U></td>
<% if (f = "e") then %>
<td><select name='Deal_stat us' size='1' style='width:13 0;'>
<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:#0 000FF;">WON</option>
<% if (strRequestActi ve = "AllClosed" ) then %>
<option value='LOST'
<% if strDealStatus = "LOST" then %>
selected
<% end if %>
style="color:#F F0000;">LOST</option></td>
<% end if %>
<% else %>
<td height="22" bgcolor="#FFFFF F" style="border:s olid 2 #006600;">  ;<%= strDealStatus %></td>
<% end if %>
<td colspan="2"><im g src="/salesdesk/images/spacer.gif" width="1" height="12" border="0"></td>
</tr>
<tr>
<td colspan="4"><im g 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="javascrip t:history.go(-1)">
<img src="/salesdesk/images/button_cancel.g if" 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("D eal_number") _
' & "', Description = '" & request.form("D escription") _
' & "', DealStatus = '" & request.form("D eal_status") _
'& "' where DealID = " & request.form("D eal_id")
' else
strSQL = "INSERT INTO tblMaint "_
& "(ClientName,Co mpletedMaintAgr ee,CreatedFolde r,AddClienttoSa lesdesk,AddCont acttoSalesdesk, AddAssettoSales desk,SendFaxtoM ail,DebitOrderS igned,Policiesa ndProcedures,Fa xOrderForm,Mail WelcomeLetter,S etupTools,Setup ServerIP,Ensure Backups,SetupVP N,BCTrain,Setup VNC,Subscribeto Newsletter,Addt oSQL,PCCleanups ) " _
& "values ('" & request.form("s trClientName") & "', '" _
& request.form("C ompletedMaintAg ree") & "', '" _
& request.form("C reatedFolder") & "', '" _
& request.form("A ddClienttoSales desk") & "', '" _
& request.form("A ddContacttoSale sdesk") & "', '" _
& request.form("A ddAssettoSalesd esk") & "', '" _
& request.form("S endFaxtoMail") & "', '" _
& request.form("D ebitOrderSigned ") & "', '" _
& request.form("P oliciesandProce dures") & "', '" _
& request.form("F axOrderForm") & "', '" _
& request.form("M ailWelcomeLette r") & "', '" _
& request.form("S etupTools") & "', '" _
& request.form("S etupServerIP") & "', '" _
& request.form("E nsureBackups") & "', '" _
& request.form("S etupVPN") & "', '" _
& request.form("B CTrain") & "', '" _
& request.form("S etupVNC") & "', '" _
& request.form("S ubscribetoNewsl etter") & "', '" _
& request.form("A ddtoSQL") & "', '" _
& request.form("P CCleanups") & "')"
' Adding new Contact. Insert new record...
'strSQL = "INSERT INTO tblDeal " _
' & "(ClientID, DealNumber, Description, DealStatus) " _
' & "values (" & CInt(request.fo rm("company_id" )) & "', '" _
'& CInt(request.fo rm("Deal_number ")) & "', '" _
'& request.form("D escription") & "', '" _
'& request.form("D eal_status") & "')" _
'end if
'on error resume next
obj_Conn.execut e(strSQL)
%>
<div align="center" style="color:#0 06600; 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.g if" alt="Edit Deal" width="80" height="20" border="0"></a>
</div>
<%
end sub
'----------------------------------
sub NoSubmit
if f = "e" then
strSQL = "SELECT * from tblDeal, tblClient " _
& "where tblDeal.ClientI D = tblClient.Clien tID " _
& "and tblClient.Clien tStatus = 'CURRENT' order by ClientName, DealNumber"
set objRS = obj_Conn.execut e(strSQL)
if not objRS.eof then
%>
<table border="0" cellpadding="0" cellspacing="0" >
<form method='post' action='/salesdesk/maint/workflowmaint.a sp' name='theForm'>
<input type='hidden' name='f' value='<%= f %>'>
<input type='hidden' name='submit1' value='True'>
<br>
<tr>
<td colspan="2">Sel ect the Deal to Edit:</td>
</tr>
<tr>
<td colspan="2"><im g src="/salesdesk/images/spacer.gif" alt="" width="1" height="2" border="0"></td>
</tr>
<tr>
<td colspan="2"><se lect name='Deal_id' size='1' style='width:35 0;'>
<% do until objRS.eof %>
<option value='<%= objRS("DealID") %>'><%= objRS("ClientNa me") %> - <%= objRS("DealNumb er") %></option>
<%
objRS.movenext
loop
%>
</select></td>
</tr>
<tr>
<td colspan="2"><im g src="/salesdesk/images/spacer.gif" alt="" width="1" height="15" border="0"></td>
</tr>
<tr>
<td><a href="javascrip t:history.go(-1)">
<img src="/salesdesk/images/button_cancel.g if" 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.Clien tStatus = 'CURRENT' order by ClientName"
set objRS = obj_Conn.execut e(strSQL)
if not objRS.eof then
%>
<table border="0" cellpadding="0" cellspacing="0" >
<form method='post' action='/salesdesk/workflowmaint.a sp' 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">Wor kflow:</td>
</tr>
<tr>
<td colspan="2"><im g src="/salesdesk/images/spacer.gif" alt="" width="1" height="2" border="0"></td>
</tr>
<tr>
<td colspan="2"><se lect name='company_i d' size='1' style='width:35 0;'>
<% do until objRS.eof %>
<option value='<%= objRS("ClientID ") %>'><%= objRS("ClientNa me") %></option>
<%
objRS.movenext
loop
%>
</select></td>
</tr>
<tr>
<td colspan="2"><im g src="/salesdesk/images/spacer.gif" alt="" width="1" height="15" border="0"></td>
</tr>
<tr>
<td><a href="javascrip t:history.go(-1)">
<img src="/salesdesk/images/button_cancel.g if" 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="JavaS cript">
<!--
var Dealid = new Array();
var Dealno = new Array();
function loadDeals() {
<%
if (request("submi t1") = "True") or (indDirectEdit) then
strSQL = "SELECT * FROM tblDeal where ClientID = " & iClientID
set objRS = obj_conn.execut e(strSQL)
do until objRS.EOF
%>
Dealid[Dealid.length] = <%= objRS("DealID") %>;
Dealno[Dealno.length] = "<%= objRS("DealNumb er") %>";
<%
objRS.movenext
loop
Set objRS = Nothing
end if
%>
}
function checkrequired(w hich) {
var pass=true;
if (pass) {
RequiredField = document.theFor m.Deal_number.v alue;
EmptyField = true;
for (var i = 0; i < RequiredField.l ength; i++) {
if (RequiredField. substr(i,1) > " ") {
EmptyField = false;
break;
}
}
if (EmptyField) {
alert("Please Supply the Deal Name");
document.theFor m.Deal_number.f ocus();
pass = false;
}
}
if (pass) {
if (document.theFo rm.Deal_number. value.indexOf(" '") > -1) {
alert("The Deal Name\n"
+"contains an apostrophe ['] (single quote)\n"
+"which is an invalid character");
document.theFor m.Deal_number.f ocus();
pass = false;
}
}
<% if f = "a" then %>
if (pass) {
var selectedDealno = document.theFor m.Deal_number.v alue;
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.theFor m.Deal_number.f ocus();
pass = false;
break;
}
}
}
<% else %>
if (pass) {
var selectedDealno = document.theFor m.Deal_number.v alue;
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.theFor m.Deal_number.f ocus();
pass = false;
break;
}
}
}
}
<% end if %>
if (pass) {
RequiredField = document.theFor m.description.v alue;
EmptyField = true;
for (var i = 0; i < RequiredField.l ength; i++) {
if (RequiredField. substr(i,1) > " ") {
EmptyField = false;
break;
}
}
if (EmptyField) {
alert("Please Supply a Description of the Deal");
document.theFor m.description.f ocus();
pass = false;
}
}
if (pass) {
if (document.theFo rm.description. value.indexOf(" '") > -1) {
alert("The Deal Description\n"
+"contains an apostrophe ['] (single quote)\n"
+"which is an invalid character");
document.theFor m.description.f ocus();
pass = false;
}
}
if (pass) {
if (document.theFo rm.deal_value.v alue.indexOf("' ") > -1) {
alert("The Deal's Value\n"
+"contains an apostrophe ['] (single quote)\n"
+"which is an invalid character");
document.theFor m.deal_value.fo cus();
pass = false;
}
}
if (pass) {
if (document.theFo rm.QuoteNumber. value.indexOf(" '") > -1) {
alert("The QuoteNumber Details\n"
+"contain an apostrophe ['] (single quote)\n"
+"which is an invalid character");
document.theFor m.QuoteNumber.f ocus();
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="loadDea ls()">
<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(dateandti me)
'If Len(myMonth)=1 Then myMonth="0" & myMonth
'myYear = Year(dateandtim e)
'AccessDateTime = myYear & "-" & myMonth & "-" & myDay & " " & Time()
'End Function
'sConnString="P ROVIDER=Microso ft.Jet.OLEDB.4. 0;" & _
'"Data Source=" & Server.MapPath( "/salesdesk/database/Saleshelpdesk.m db")
'Set connection = Server.CreateOb ject("ADODB.Con nection")
'connection.Ope n(sConnString)
'Dim connection
'Dim SQL, sConnString
'the DateTime is the field in the DataBase
'SQL="INSERT INTO tblMaint(DateTi me) VALUES (#" & AccessDateTime( NOW()) & "#)"
'connection.exe cute(SQL)
'Connection.Clo se
'Set Connection = Nothing
%>