Forums
This topic is locked
EDIT product but OPTION not showing all Categories
29 Jul 2007 22:53:47 John Doo posted:
<font face='Arial'>Hi guys,<br>Wonder if any one can help me out, I'm tearing my hair out, as they say!<br><br>
I have Categories and various Products in each Category. I'm trying to build a page to EDIT/UPDATE each product. See <a href="www.ollielaroo.net/pages/admin_products.asp">here</a>.<br>
I want to be able to change the Category that a product belongs to, but all I get in the drop-down menu is the one specific Category. I have two recordsets on my edit_product.asp page: rsResults and rsCategories.
If anyone can help I would very much appreciate it <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Here is the code of 'edit_product.asp'
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include virtual="Connections/homes_connect.asp" -->
<%
Dim rsEditRecord__var_prodid
rsEditRecord__var_prodid = "1"
If (Request.QueryString("ID" <> "" Then
rsEditRecord__var_prodid = Request.QueryString("ID"
End If
%>
<%
Dim rsEditRecord
Dim rsEditRecord_numRows
Set rsEditRecord = Server.CreateObject("ADODB.Recordset"
rsEditRecord.ActiveConnection = MM_homes_connect_STRING
rsEditRecord.Source = "SELECT * FROM data WHERE ID = " + Replace(rsEditRecord__var_prodid, "'", "''" + ""
rsEditRecord.CursorType = 0
rsEditRecord.CursorLocation = 2
rsEditRecord.LockType = 1
rsEditRecord.Open()
rsEditRecord_numRows = 0
%>
<%
Dim rsCategories__var_prodid
rsCategories__var_prodid = "1"
If (Request.QueryString("ID" <> "" Then
rsCategories__var_prodid = Request.QueryString("ID"
End If
%>
<%
Dim rsCategories
Dim rsCategories_numRows
Set rsCategories = Server.CreateObject("ADODB.Recordset"
rsCategories.ActiveConnection = MM_homes_connect_STRING
rsCategories.Source = "SELECT * FROM data, cat WHERE ID = " + Replace(rsCategories__var_prodid, "'", "''" + " AND data.catid = cat.catid"
rsCategories.CursorType = 0
rsCategories.CursorLocation = 2
rsCategories.LockType = 1
rsCategories.Open()
rsCategories_numRows = 0
%>
<%
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")
If (Request.QueryString <> "" Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update") = "Edit" And CStr(Request("MM_recordId") <> "" Then
MM_editConnection = MM_homes_connect_STRING
MM_editTable = "data"
MM_editColumn = "ID"
MM_recordId = "" + Request.Form("MM_recordId" + ""
MM_editRedirectUrl = "confirm_edit_product.asp"
MM_fieldsStr = "name|value|catid|value|value|product_pic|value|brief_desc|value|full_desc|value|specs_title|value|specs|value|brochure1_name|value|brochure1_type|value|brochure1|value|brochure2_name|value|brochure2_type|value|brochure2|value|brochure3_name|value|brochure3_type|value|brochure3|value|pic_1|value|pic_2|value|pic_3|value"
MM_columnsStr = "name|',none,''|catid|',none,''|product_pic|',none,''|brief_desc|',none,''|full_desc|',none,''|specs_title|',none,''|specs|',none,''|brochure1_name|',none,''|brochure1_type|',none,''|brochure1|',none,''|brochure2_name|',none,''|brochure2_type|',none,''|brochure2|',none,''|brochure3_name|',none,''|brochure3_type|',none,''|brochure3|',none,''|pic_1|',none,''|pic_2|',none,''|pic_3|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update") <> "" And CStr(Request("MM_recordId") <> "" Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),","
MM_delim = MM_typeArray(0)
If (MM_delim = "none" Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none" Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none" Then MM_emptyVal = ""
If (MM_formVal = "" Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "" Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'" Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''" & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set 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 <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Edit Product </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
color: #000066;
}
.style3 {color: #000000}
.style4 {color: #000066; font-family: Arial, Helvetica, sans-serif;}
.style5 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
<link href="/style.css" rel="stylesheet" type="text/css">
<style>
<!--
/*Website Abstraction www.wsabstract.com More scripts here*/
a{text-decoration:none}
//-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center">
<form ACTION="<%=MM_editAction%>" METHOD="post" name="Edit" id="Edit">
<div align="left">
<table width="802" border="0" cellpadding="2" cellspacing="2" bgcolor="#F5FDFE" align="center">
<!--DWLayoutTable-->
<tr>
<td height="43" colspan="5" valign="top" bgcolor="#000066"><div align="left"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif"> ID:
<%=(rsEditRecord.Fields.Item("ID".Value)%> </font></strong></div></td>
<td colspan="4" valign="top" bgcolor="#000066"> <div align="center"><font color="#FFFFFF" size="5" face="Arial, Helvetica, sans-serif"><strong>EDIT
PRODUCT</strong></font></div></td>
<td colspan="6" valign="top" bgcolor="#000066"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td width="1" height="17"></td>
<td width="4"></td>
<td width="104"></td>
<td width="13"></td>
<td width="131"></td>
<td width="114"></td>
<td width="2"></td>
<td width="91"></td>
<td width="8"></td>
<td width="2"></td>
<td width="50"></td>
<td width="8"></td>
<td width="89"></td>
<td width="10"></td>
<td width="83"></td>
</tr>
<tr>
<td rowspan="33" valign="top"><!--DWLayoutEmptyCell--> </td>
<td height="12"></td>
</tr>
<tr>
<td height="23" colspan="2" valign="top" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"><strong>Product
Name</strong></font></td>
<td colspan="3" rowspan="2" valign="top" class="Edit-Delete-FORM"><div align="left"><font face="Arial, Helvetica, sans-serif"></font>
<input name="name" type="text" id="name" value="<%=(rsEditRecord.Fields.Item("name".Value)%>" size="30">
</div></td>
<td colspan="2" rowspan="2" valign="top" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"><strong>Product
Category</strong></font></td>
<td colspan="7" rowspan="2" valign="top"> <select name="catid" id="catid">
<%
While (NOT rsCategories.EOF)
%>
<%
rsCategories.MoveNext()
Wend
If (rsCategories.CursorType > 0) Then
rsCategories.MoveFirst
Else
rsCategories.Requery
End If
%>
<%
While (NOT rsCategories.EOF)
%>
<option value="<%=(rsCategories.Fields.Item("category".Value)%>" <%If (Not isNull((rsCategories.Fields.Item("category".Value))) Then If (CStr(rsCategories.Fields.Item("category".Value) = CStr((rsCategories.Fields.Item("category".Value))) Then Response.Write("SELECTED" : Response.Write("1"%> ><%=(rsCategories.Fields.Item("category".Value)%></option>
<%
rsCategories.MoveNext()
Wend
If (rsCategories.CursorType > 0) Then
rsCategories.MoveFirst
Else
rsCategories.Requery
End If
%>
</select></td>
</tr>
<tr>
<td height="3"></td>
<td></td>
</tr>
<tr>
<td height="11"></td>
<td colspan="2" rowspan="4" valign="top"><img src="/<%=(rsEditRecord.Fields.Item("product_pic".Value)%>" alt="" width="100" height="80" align="middle"></td>
<td></td>
</tr>
<tr>
<td height="45" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong><br>
Product Picture</strong></font></td>
<td colspan="8" rowspan="2" valign="top"><p align="left"><font color="#000000" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#000000" face="Arial, Helvetica, sans-serif">
<input name="product_pic" type="text" id="product_pic" value="<%=(rsEditRecord.Fields.Item("product_pic".Value)%>" size="60">
</font></strong></font><strong><font color="#000000" face="Arial, Helvetica, sans-serif">
</font></strong></p></td>
<td> </td>
<td></td>
</tr>
<tr>
<td height="18"></td>
</tr>
<tr>
<td height="14"></td>
</tr>
<tr>
<td height="11"></td>
<td></td>
<td colspan="10" rowspan="2" valign="top"><p align="left" class="FormElement">
<textarea name="brief_desc" cols="60" rows="2" id="brief_desc"><%=(rsEditRecord.Fields.Item("brief_desc".Value)%></textarea>
</p></td>
</tr>
<tr>
<td height="79" colspan="2" valign="top" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"><strong>Brief
Description</strong></font></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="11"></td>
<td></td>
<td colspan="10" rowspan="3" valign="top" bgcolor="#F5FDFE"> <p align="left" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"></font>
<textarea name="full_desc" cols="70" rows="12" id="full_desc"><%=(rsEditRecord.Fields.Item("full_desc".Value)%></textarea>
</p></td>
</tr>
<tr>
<td height="78" colspan="2" valign="top" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"><strong>Full
Description</strong></font></td>
</tr>
<tr>
<td height="143"> </td>
<td> </td>
</tr>
<tr>
<td height="30" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Specs
Title</strong></font></td>
<td colspan="10" valign="top"><input name="specs_title" type="text" id="specs_title" value="<%= rsEditRecord.Fields.Item("specs_title".Value %>" size="50">
<font size="2"> Custom heading</font></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="138" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Specifications</strong></font></td>
<td colspan="10" valign="top"><textarea name="specs" cols="50" rows="7" id="specs"><%= rsEditRecord.Fields.Item("specs".Value %></textarea></td>
</tr>
<tr>
<td height="37" colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
1 Name</strong></font></td>
<td colspan="3" valign="top"><input name="brochure1_name" type="text" id="brochure1_name" value="<%= rsEditRecord.Fields.Item("brochure1_name".Value %>" size="30"></td>
<td colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
1 Type</strong></font></td>
<td colspan="3" valign="top"><select name="brochure1_type" id="brochure1_type">
<option value="empty.jpg" <%If (Not isNull((rsEditRecord.Fields.Item("brochure1_type".Value))) Then If ("empty.jpg" = CStr((rsEditRecord.Fields.Item("brochure1_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>NONE
</option>
<option value="images/SITE/pdf.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure1_type".Value))) Then If ("images/SITE/pdf.gif" = CStr((rsEditRecord.Fields.Item("brochure1_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Adobe.pdf
</option>
<option value="images/SITE/word.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure1_type".Value))) Then If ("images/SITE/word.gif" = CStr((rsEditRecord.Fields.Item("brochure1_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Word.doc
</option>
<option value="images/SITE/excel.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure1_type".Value))) Then If ("images/SITE/excel.gif" = CStr((rsEditRecord.Fields.Item("brochure1_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Excel.xls
</option>
</select></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="37" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
1 File</strong></font></td>
<td colspan="10" valign="top"><input name="brochure1" type="text" id="brochure1" value="<%= rsEditRecord.Fields.Item("brochure1".Value %>" size="80"></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="11"></td>
</tr>
<tr>
<td height="37" colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
2 Name</strong></font></td>
<td colspan="3" valign="top"><input name="brochure2_name" type="text" id="brochure2_name" value="<%= rsEditRecord.Fields.Item("brochure2_name".Value %>" size="30"></td>
<td colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
2 Type</strong></font></td>
<td colspan="3" valign="top"><select name="brochure2_type" id="select3">
<option value="empty.jpg" <%If (Not isNull((rsEditRecord.Fields.Item("brochure2_type".Value))) Then If ("empty.jpg" = CStr((rsEditRecord.Fields.Item("brochure2_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>NONE
</option>
<option value="images/SITE/pdf.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure2_type".Value))) Then If ("images/SITE/pdf.gif" = CStr((rsEditRecord.Fields.Item("brochure2_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Adobe.pdf
</option>
<option value="images/SITE/word.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure2_type".Value))) Then If ("images/SITE/word.gif" = CStr((rsEditRecord.Fields.Item("brochure2_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Word.doc
</option>
<option value="images/SITE/excel.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure2_type".Value))) Then If ("images/SITE/excel.gif" = CStr((rsEditRecord.Fields.Item("brochure2_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Excel.xls
</option>
</select></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="36" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
2 File</strong></font></td>
<td colspan="10" valign="top"><input name="brochure2" type="text" id="brochure2" value="<%= rsEditRecord.Fields.Item("brochure2".Value %>" size="80"></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="11"></td>
</tr>
<tr>
<td height="37" colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
3 Name</strong></font></td>
<td colspan="3" valign="top"><input name="brochure3_name" type="text" id="brochure3_name" value="<%= rsEditRecord.Fields.Item("brochure3_name".Value %>" size="30"></td>
<td colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
3 Type</strong></font></td>
<td colspan="3" valign="top"><select name="brochure3_type" id="select4">
<option value="empty.jpg" <%If (Not isNull((rsEditRecord.Fields.Item("brochure3_type".Value))) Then If ("empty.jpg" = CStr((rsEditRecord.Fields.Item("brochure3_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>NONE
</option>
<option value="images/SITE/pdf.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure3_type".Value))) Then If ("images/SITE/pdf.gif" = CStr((rsEditRecord.Fields.Item("brochure3_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Adobe.pdf
</option>
<option value="images/SITE/word.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure3_type".Value))) Then If ("images/SITE/word.gif" = CStr((rsEditRecord.Fields.Item("brochure3_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Word.doc
</option>
<option value="images/SITE/excel.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure3_type".Value))) Then If ("images/SITE/excel.gif" = CStr((rsEditRecord.Fields.Item("brochure3_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Excel.xls
</option>
</select></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="36" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
3 File</strong></font></td>
<td colspan="10" valign="top"><input name="brochure3" type="text" id="brochure3" value="<%= rsEditRecord.Fields.Item("brochure3".Value %>" size="80"></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td height="9"></td>
<td rowspan="2" valign="top" class="Edit-Delete-FORM"> <p align="left"><font color="#000033" size="2">Detail
Pic 1</font></p></td>
</tr>
<tr>
<td height="27"> </td>
<td colspan="10" valign="top"><input name="pic_1" type="text" id="pic_1" value="<%=(rsEditRecord.Fields.Item("pic_1".Value)%>" size="70"></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="96" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td colspan="10" valign="top"><p><img src="/<%=(rsEditRecord.Fields.Item("pic_1".Value)%>" alt="" align="left"></p>
<p> </p>
<p> </p></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="10"></td>
<td rowspan="2" valign="top"> <p align="left"><font color="#000033" size="2"><strong>Detail
Pic 2</strong></font></p></td>
</tr>
<tr>
<td height="26"></td>
<td colspan="10" valign="top"><input name="pic_2" type="text" id="pic_22" value="<%=(rsEditRecord.Fields.Item("pic_2".Value)%>" size="70"></td>
</tr>
<tr>
<td height="86" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td colspan="10" valign="top"><p><img src="/<%=(rsEditRecord.Fields.Item("pic_2".Value)%>" alt=""></p>
<p> </p></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="11"></td>
<td rowspan="2" valign="top" bgcolor="#F5FDFE"> <p align="left"><font color="#000066" face="Arial, Helvetica, sans-serif"><strong> </strong></font><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Detail
Pic 3</strong></font></p></td>
</tr>
<tr>
<td height="42"></td>
<td colspan="10" valign="top"><font color="#000066" face="Arial, Helvetica, sans-serif"><strong><font color="#000000">
<input name="pic_3" type="text" id="pic_32" value="<%=(rsEditRecord.Fields.Item("pic_3".Value)%>" size="70">
</font></strong></font></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="49" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td colspan="10" valign="top"><img src="/<%=(rsEditRecord.Fields.Item("pic_3".Value)%>" alt=""></td>
</tr>
<tr>
<td height="64" colspan="14" valign="top"> <div align="center">
<p> <br>
<input type="submit" name="Submit" value="Edit Product">
</p>
</div></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="Edit">
<input type="hidden" name="MM_recordId" value="<%= rsEditRecord.Fields.Item("ID".Value %>">
</div>
</form>
<p align="center" class="style1"><a href="javascript:history.go(-1)"><font color="#000066" size="3" face="Arial, Helvetica, sans-serif"><<
BACK</font></a></p>
</div>
</body>
</html>
<%
rsEditRecord.Close()
Set rsEditRecord = Nothing
%>
<%
rsCategories.Close()
Set rsCategories = Nothing
%>
</font id='Arial'>
Thanks in advance for any help.
John
Replies
Replied 30 Jul 2007 23:35:50
30 Jul 2007 23:35:50 John Doo replied:
OK here I go again.
PRODUCTS TABLE is still called 'data' ID is the PK
CATEGORIES TABLE is still called 'cat' catid is the FK
This time I think I should be using just one recordset 'rsEditRecord' right?
...trying to update the value for the product 'ID'.
www.ollielaroo.net/pages/admin_products.asp
My code is now different obviously, but still, where I want to have the CATEGORIES dropdown menu, to edit the Category, I get this famous error:
"Item cannot be found in the collection corresponding to the requested name or ordinal, /edit_product.asp line 232"
Here is my code:
------------------------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include virtual="Connections/homes_connect.asp" -->
<%
Dim rsEditRecord__var_prodid
rsEditRecord__var_prodid = "1"
If (Request.QueryString("ID" <> "" Then
rsEditRecord__var_prodid = Request.QueryString("ID"
End If
%>
<%
Dim rsEditRecord
Dim rsEditRecord_numRows
Set rsEditRecord = Server.CreateObject("ADODB.Recordset"
rsEditRecord.ActiveConnection = MM_homes_connect_STRING
rsEditRecord.Source = "SELECT * FROM data, cat WHERE ID = " + Replace(rsEditRecord__var_prodid, "'", "''" + " AND data.catid = cat.catid"
rsEditRecord.CursorType = 0
rsEditRecord.CursorLocation = 2
rsEditRecord.LockType = 1
rsEditRecord.Open()
rsEditRecord_numRows = 0
%>
<%
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")
If (Request.QueryString <> "" Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update") = "Edit" And CStr(Request("MM_recordId") <> "" Then
MM_editConnection = MM_homes_connect_STRING
MM_editTable = "data"
MM_editColumn = "ID"
MM_recordId = "" + Request.Form("MM_recordId" + ""
MM_editRedirectUrl = "confirm_edit_product.asp"
MM_fieldsStr = "name|value|catid|value|product_pic|value|brief_desc|value|full_desc|value|specs_title|value|specs|value|brochure1_name|value|brochure1_type|value|brochure1|value|brochure2_name|value|brochure2_type|value|brochure2|value|brochure3_name|value|brochure3_type|value|brochure3|value|pic_1|value|pic_2|value|pic_3|value"
MM_columnsStr = "name|',none,''|catid|',none,''|product_pic|',none,''|brief_desc|',none,''|full_desc|',none,''|specs_title|',none,''|specs|',none,''|brochure1_name|',none,''|brochure1_type|',none,''|brochure1|',none,''|brochure2_name|',none,''|brochure2_type|',none,''|brochure2|',none,''|brochure3_name|',none,''|brochure3_type|',none,''|brochure3|',none,''|pic_1|',none,''|pic_2|',none,''|pic_3|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update") <> "" And CStr(Request("MM_recordId") <> "" Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),","
MM_delim = MM_typeArray(0)
If (MM_delim = "none" Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none" Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none" Then MM_emptyVal = ""
If (MM_formVal = "" Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "" Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'" Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''" & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set 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 <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Edit Product </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
color: #000066;
}
.style3 {color: #000000}
.style4 {color: #000066; font-family: Arial, Helvetica, sans-serif;}
.style5 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
<link href="/style.css" rel="stylesheet" type="text/css">
<style>
<!--
/*Website Abstraction www.wsabstract.com More scripts here*/
a{text-decoration:none}
//-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center">
<form ACTION="<%=MM_editAction%>" METHOD="post" name="Edit" id="Edit">
<div align="left">
<table width="795" border="0" cellpadding="2" cellspacing="2" bgcolor="#F5FDFE" align="center">
<!--DWLayoutTable-->
<tr>
<td height="43" colspan="5" valign="top" bgcolor="#000066"><div align="left"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif"> ID:
<%=(rsEditRecord.Fields.Item("ID".Value)%> </font></strong></div></td>
<td colspan="4" valign="top" bgcolor="#000066"> <div align="center"><font color="#FFFFFF" size="5" face="Arial, Helvetica, sans-serif"><strong>EDIT
PRODUCT</strong></font></div></td>
<td colspan="3" valign="top" bgcolor="#000066"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td width="1" height="17"></td>
<td width="3"></td>
<td width="90"></td>
<td width="8"></td>
<td width="119"></td>
<td width="103"></td>
<td width="2"></td>
<td width="114"></td>
<td width="6"></td>
<td width="2"></td>
<td width="207"></td>
<td width="66"></td>
</tr>
<tr>
<td rowspan="33" valign="top"><!--DWLayoutEmptyCell--> </td>
<td height="12"></td>
</tr>
<tr>
<td height="23" colspan="2" valign="top" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"><strong>Product
Name</strong></font></td>
<td colspan="3" rowspan="2" valign="top" class="Edit-Delete-FORM"><div align="left"><font face="Arial, Helvetica, sans-serif"></font>
<input name="name" type="text" id="name" value="<%=(rsEditRecord.Fields.Item("name".Value)%>" size="30">
</div></td>
<td colspan="2" rowspan="2" valign="top" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"><strong>Product
Category</strong></font></td>
<td colspan="4" rowspan="2" valign="top"> <select name="catid" id="catid">
<%
While (NOT rsEditRecord.EOF)
%>
<%
rsEditRecord.MoveNext()
Wend
If (rsEditRecord.CursorType > 0) Then
rsEditRecord.MoveFirst
Else
rsEditRecord.Requery
End If
%>
<%
While (NOT rsEditRecord.EOF)
%>
<option value="<%=(rsEditRecord.Fields.Item("catid".Value)%>" <%If (Not isNull((rsEditRecord.Fields.Item("catid".Value))) Then If (CStr(rsEditRecord.Fields.Item("catid".Value) = CStr((rsEditRecord.Fields.Item("catid".Value))) Then Response.Write("SELECTED" : Response.Write(""%> ><%=(rsEditRecord.Fields.Item("catid".Value)%></option>
<%
rsEditRecord.MoveNext()
Wend
If (rsEditRecord.CursorType > 0) Then
rsEditRecord.MoveFirst
Else
rsEditRecord.Requery
End If
%>
</select></td>
</tr>
<tr>
<td height="3"></td>
</tr>
<tr>
<td height="11"></td>
</tr>
<tr>
<td height="45" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong><br>
Product Picture</strong></font></td>
<td colspan="7" rowspan="2" valign="top"><p align="left"><font color="#000000" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#000000" face="Arial, Helvetica, sans-serif">
<input name="product_pic" type="text" id="product_pic" value="<%=(rsEditRecord.Fields.Item("product_pic".Value)%>" size="60">
</font></strong></font><strong><font color="#000000" face="Arial, Helvetica, sans-serif">
</font></strong></p></td>
<td rowspan="3" valign="top"><img src="/<%=(rsEditRecord.Fields.Item("product_pic".Value)%>" alt="" width="100" height="80" align="middle"></td>
<td> </td>
</tr>
<tr>
<td height="18"></td>
</tr>
<tr>
<td height="14"></td>
</tr>
<tr>
<td height="11"></td>
<td colspan="8" rowspan="2" valign="top"><p align="left" class="FormElement">
<textarea name="brief_desc" cols="60" rows="2" id="brief_desc"><%=(rsEditRecord.Fields.Item("brief_desc".Value)%></textarea>
</p></td>
</tr>
<tr>
<td height="79" colspan="2" valign="top" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"><strong>Brief
Description</strong></font></td>
</tr>
<tr>
<td height="11"></td>
<td colspan="8" rowspan="3" valign="top" bgcolor="#F5FDFE"> <p align="left" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"></font>
<textarea name="full_desc" cols="70" rows="12" id="full_desc"><%=(rsEditRecord.Fields.Item("full_desc".Value)%></textarea>
</p></td>
</tr>
<tr>
<td height="78" colspan="2" valign="top" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"><strong>Full
Description</strong></font></td>
</tr>
<tr>
<td height="143"> </td>
<td> </td>
</tr>
<tr>
<td height="30" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Specs
Title</strong></font></td>
<td colspan="8" valign="top"><input name="specs_title" type="text" id="specs_title" value="<%= rsEditRecord.Fields.Item("specs_title".Value %>" size="50">
<font size="2"> Custom heading</font></td>
</tr>
<tr>
<td height="138" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Specifications</strong></font></td>
<td colspan="8" valign="top"><textarea name="specs" cols="50" rows="7" id="specs"><%= rsEditRecord.Fields.Item("specs".Value %></textarea></td>
</tr>
<tr>
<td height="37" colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
1 Name</strong></font></td>
<td colspan="3" valign="top"><input name="brochure1_name" type="text" id="brochure1_name" value="<%= rsEditRecord.Fields.Item("brochure1_name".Value %>" size="30"></td>
<td colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
1 Type</strong></font></td>
<td valign="top"><select name="brochure1_type" id="brochure1_type">
<option value="empty.jpg" <%If (Not isNull((rsEditRecord.Fields.Item("brochure1_type".Value))) Then If ("empty.jpg" = CStr((rsEditRecord.Fields.Item("brochure1_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>NONE
</option>
<option value="images/SITE/pdf.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure1_type".Value))) Then If ("images/SITE/pdf.gif" = CStr((rsEditRecord.Fields.Item("brochure1_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Adobe.pdf
</option>
<option value="images/SITE/word.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure1_type".Value))) Then If ("images/SITE/word.gif" = CStr((rsEditRecord.Fields.Item("brochure1_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Word.doc
</option>
<option value="images/SITE/excel.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure1_type".Value))) Then If ("images/SITE/excel.gif" = CStr((rsEditRecord.Fields.Item("brochure1_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Excel.xls
</option>
</select></td>
<td> </td>
</tr>
<tr>
<td height="37" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
1 File</strong></font></td>
<td colspan="8" valign="top"><input name="brochure1" type="text" id="brochure1" value="<%= rsEditRecord.Fields.Item("brochure1".Value %>" size="80"></td>
<td> </td>
</tr>
<tr>
<td height="11"></td>
</tr>
<tr>
<td height="37" colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
2 Name</strong></font></td>
<td colspan="3" valign="top"><input name="brochure2_name" type="text" id="brochure2_name" value="<%= rsEditRecord.Fields.Item("brochure2_name".Value %>" size="30"></td>
<td colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
2 Type</strong></font></td>
<td valign="top"><select name="brochure2_type" id="select3">
<option value="empty.jpg" <%If (Not isNull((rsEditRecord.Fields.Item("brochure2_type".Value))) Then If ("empty.jpg" = CStr((rsEditRecord.Fields.Item("brochure2_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>NONE
</option>
<option value="images/SITE/pdf.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure2_type".Value))) Then If ("images/SITE/pdf.gif" = CStr((rsEditRecord.Fields.Item("brochure2_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Adobe.pdf
</option>
<option value="images/SITE/word.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure2_type".Value))) Then If ("images/SITE/word.gif" = CStr((rsEditRecord.Fields.Item("brochure2_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Word.doc
</option>
<option value="images/SITE/excel.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure2_type".Value))) Then If ("images/SITE/excel.gif" = CStr((rsEditRecord.Fields.Item("brochure2_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Excel.xls
</option>
</select></td>
</tr>
<tr>
<td height="36" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
2 File</strong></font></td>
<td colspan="8" valign="top"><input name="brochure2" type="text" id="brochure2" value="<%= rsEditRecord.Fields.Item("brochure2".Value %>" size="80"></td>
<td></td>
</tr>
<tr>
<td height="11"></td>
</tr>
<tr>
<td height="37" colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
3 Name</strong></font></td>
<td colspan="3" valign="top"><input name="brochure3_name" type="text" id="brochure3_name" value="<%= rsEditRecord.Fields.Item("brochure3_name".Value %>" size="30"></td>
<td colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
3 Type</strong></font></td>
<td valign="top"><select name="brochure3_type" id="select4">
<option value="empty.jpg" <%If (Not isNull((rsEditRecord.Fields.Item("brochure3_type".Value))) Then If ("empty.jpg" = CStr((rsEditRecord.Fields.Item("brochure3_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>NONE
</option>
<option value="images/SITE/pdf.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure3_type".Value))) Then If ("images/SITE/pdf.gif" = CStr((rsEditRecord.Fields.Item("brochure3_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Adobe.pdf
</option>
<option value="images/SITE/word.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure3_type".Value))) Then If ("images/SITE/word.gif" = CStr((rsEditRecord.Fields.Item("brochure3_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Word.doc
</option>
<option value="images/SITE/excel.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure3_type".Value))) Then If ("images/SITE/excel.gif" = CStr((rsEditRecord.Fields.Item("brochure3_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Excel.xls
</option>
</select></td>
<td></td>
</tr>
<tr>
<td height="36" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
3 File</strong></font></td>
<td colspan="8" valign="top"><input name="brochure3" type="text" id="brochure3" value="<%= rsEditRecord.Fields.Item("brochure3".Value %>" size="80"></td>
<td> </td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td height="9"></td>
<td rowspan="2" valign="top" class="Edit-Delete-FORM"> <p align="left"><font color="#000033" size="2">Detail
Pic 1</font></p></td>
</tr>
<tr>
<td height="27"> </td>
<td colspan="8" valign="top"><input name="pic_1" type="text" id="pic_1" value="<%=(rsEditRecord.Fields.Item("pic_1".Value)%>" size="70"></td>
<td></td>
</tr>
<tr>
<td height="96" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td colspan="8" valign="top"><p><img src="/<%=(rsEditRecord.Fields.Item("pic_1".Value)%>" alt="" align="left"></p>
<p> </p>
<p> </p></td>
<td> </td>
</tr>
<tr>
<td height="10"></td>
<td rowspan="2" valign="top"> <p align="left"><font color="#000033" size="2"><strong>Detail
Pic 2</strong></font></p></td>
</tr>
<tr>
<td height="26"></td>
<td colspan="8" valign="top"><input name="pic_2" type="text" id="pic_22" value="<%=(rsEditRecord.Fields.Item("pic_2".Value)%>" size="70"></td>
<td> </td>
</tr>
<tr>
<td height="86" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td colspan="8" valign="top"><p><img src="/<%=(rsEditRecord.Fields.Item("pic_2".Value)%>" alt=""></p>
<p> </p></td>
<td></td>
</tr>
<tr>
<td height="11"></td>
<td rowspan="2" valign="top" bgcolor="#F5FDFE"> <p align="left"><font color="#000066" face="Arial, Helvetica, sans-serif"><strong> </strong></font><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Detail
Pic 3</strong></font></p></td>
</tr>
<tr>
<td height="42"></td>
<td colspan="8" valign="top"><font color="#000066" face="Arial, Helvetica, sans-serif"><strong><font color="#000000">
<input name="pic_3" type="text" id="pic_32" value="<%=(rsEditRecord.Fields.Item("pic_3".Value)%>" size="70">
</font></strong></font></td>
<td></td>
</tr>
<tr>
<td height="49" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td colspan="8" valign="top"><img src="/<%=(rsEditRecord.Fields.Item("pic_3".Value)%>" alt=""></td>
<td> </td>
</tr>
<tr>
<td height="64" colspan="11" valign="top"> <div align="center">
<p> <br>
<input type="submit" name="Submit" value="Edit Product">
</p>
</div></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="Edit">
<input type="hidden" name="MM_recordId" value="<%= rsEditRecord.Fields.Item("ID".Value %>">
</div>
</form>
<p align="center" class="style1"><a href="javascript:history.go(-1)"><font color="#000066" size="3" face="Arial, Helvetica, sans-serif"><<
BACK</font></a></p>
</div>
</body>
</html>
<%
rsEditRecord.Close()
Set rsEditRecord = Nothing
%>
------------------------------------------------------------------------------------
Please somebody take out of this den of inequity!! <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>
PRODUCTS TABLE is still called 'data' ID is the PK
CATEGORIES TABLE is still called 'cat' catid is the FK
This time I think I should be using just one recordset 'rsEditRecord' right?
...trying to update the value for the product 'ID'.
www.ollielaroo.net/pages/admin_products.asp
My code is now different obviously, but still, where I want to have the CATEGORIES dropdown menu, to edit the Category, I get this famous error:
"Item cannot be found in the collection corresponding to the requested name or ordinal, /edit_product.asp line 232"
Here is my code:
------------------------------------------------------------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include virtual="Connections/homes_connect.asp" -->
<%
Dim rsEditRecord__var_prodid
rsEditRecord__var_prodid = "1"
If (Request.QueryString("ID" <> "" Then
rsEditRecord__var_prodid = Request.QueryString("ID"
End If
%>
<%
Dim rsEditRecord
Dim rsEditRecord_numRows
Set rsEditRecord = Server.CreateObject("ADODB.Recordset"
rsEditRecord.ActiveConnection = MM_homes_connect_STRING
rsEditRecord.Source = "SELECT * FROM data, cat WHERE ID = " + Replace(rsEditRecord__var_prodid, "'", "''" + " AND data.catid = cat.catid"
rsEditRecord.CursorType = 0
rsEditRecord.CursorLocation = 2
rsEditRecord.LockType = 1
rsEditRecord.Open()
rsEditRecord_numRows = 0
%>
<%
' *** Edit Operations: declare variables
Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd
Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId
Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")
If (Request.QueryString <> "" Then
MM_editAction = MM_editAction & "?" & Request.QueryString
End If
' boolean to abort record edit
MM_abortEdit = false
' query string to execute
MM_editQuery = ""
%>
<%
' *** Update Record: set variables
If (CStr(Request("MM_update") = "Edit" And CStr(Request("MM_recordId") <> "" Then
MM_editConnection = MM_homes_connect_STRING
MM_editTable = "data"
MM_editColumn = "ID"
MM_recordId = "" + Request.Form("MM_recordId" + ""
MM_editRedirectUrl = "confirm_edit_product.asp"
MM_fieldsStr = "name|value|catid|value|product_pic|value|brief_desc|value|full_desc|value|specs_title|value|specs|value|brochure1_name|value|brochure1_type|value|brochure1|value|brochure2_name|value|brochure2_type|value|brochure2|value|brochure3_name|value|brochure3_type|value|brochure3|value|pic_1|value|pic_2|value|pic_3|value"
MM_columnsStr = "name|',none,''|catid|',none,''|product_pic|',none,''|brief_desc|',none,''|full_desc|',none,''|specs_title|',none,''|specs|',none,''|brochure1_name|',none,''|brochure1_type|',none,''|brochure1|',none,''|brochure2_name|',none,''|brochure2_type|',none,''|brochure2|',none,''|brochure3_name|',none,''|brochure3_type|',none,''|brochure3|',none,''|pic_1|',none,''|pic_2|',none,''|pic_3|',none,''"
' create the MM_fields and MM_columns arrays
MM_fields = Split(MM_fieldsStr, "|"
MM_columns = Split(MM_columnsStr, "|"
' set the form values
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
Next
' append the query string to the redirect URL
If (MM_editRedirectUrl <> "" And Request.QueryString <> "" Then
If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "" Then
MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString
Else
MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString
End If
End If
End If
%>
<%
' *** Update Record: construct a sql update statement and execute it
If (CStr(Request("MM_update") <> "" And CStr(Request("MM_recordId") <> "" Then
' create the sql update statement
MM_editQuery = "update " & MM_editTable & " set "
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),","
MM_delim = MM_typeArray(0)
If (MM_delim = "none" Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none" Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none" Then MM_emptyVal = ""
If (MM_formVal = "" Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "" Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'" Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''" & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_editQuery = MM_editQuery & ","
End If
MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
Next
MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = " & MM_recordId
If (Not MM_abortEdit) Then
' execute the update
Set 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 <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If
End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Edit Product </title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
color: #000066;
}
.style3 {color: #000000}
.style4 {color: #000066; font-family: Arial, Helvetica, sans-serif;}
.style5 {font-family: Arial, Helvetica, sans-serif}
-->
</style>
<link href="/style.css" rel="stylesheet" type="text/css">
<style>
<!--
/*Website Abstraction www.wsabstract.com More scripts here*/
a{text-decoration:none}
//-->
</style>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center">
<form ACTION="<%=MM_editAction%>" METHOD="post" name="Edit" id="Edit">
<div align="left">
<table width="795" border="0" cellpadding="2" cellspacing="2" bgcolor="#F5FDFE" align="center">
<!--DWLayoutTable-->
<tr>
<td height="43" colspan="5" valign="top" bgcolor="#000066"><div align="left"><strong><font color="#FFFFFF" face="Arial, Helvetica, sans-serif"> ID:
<%=(rsEditRecord.Fields.Item("ID".Value)%> </font></strong></div></td>
<td colspan="4" valign="top" bgcolor="#000066"> <div align="center"><font color="#FFFFFF" size="5" face="Arial, Helvetica, sans-serif"><strong>EDIT
PRODUCT</strong></font></div></td>
<td colspan="3" valign="top" bgcolor="#000066"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td width="1" height="17"></td>
<td width="3"></td>
<td width="90"></td>
<td width="8"></td>
<td width="119"></td>
<td width="103"></td>
<td width="2"></td>
<td width="114"></td>
<td width="6"></td>
<td width="2"></td>
<td width="207"></td>
<td width="66"></td>
</tr>
<tr>
<td rowspan="33" valign="top"><!--DWLayoutEmptyCell--> </td>
<td height="12"></td>
</tr>
<tr>
<td height="23" colspan="2" valign="top" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"><strong>Product
Name</strong></font></td>
<td colspan="3" rowspan="2" valign="top" class="Edit-Delete-FORM"><div align="left"><font face="Arial, Helvetica, sans-serif"></font>
<input name="name" type="text" id="name" value="<%=(rsEditRecord.Fields.Item("name".Value)%>" size="30">
</div></td>
<td colspan="2" rowspan="2" valign="top" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"><strong>Product
Category</strong></font></td>
<td colspan="4" rowspan="2" valign="top"> <select name="catid" id="catid">
<%
While (NOT rsEditRecord.EOF)
%>
<%
rsEditRecord.MoveNext()
Wend
If (rsEditRecord.CursorType > 0) Then
rsEditRecord.MoveFirst
Else
rsEditRecord.Requery
End If
%>
<%
While (NOT rsEditRecord.EOF)
%>
<option value="<%=(rsEditRecord.Fields.Item("catid".Value)%>" <%If (Not isNull((rsEditRecord.Fields.Item("catid".Value))) Then If (CStr(rsEditRecord.Fields.Item("catid".Value) = CStr((rsEditRecord.Fields.Item("catid".Value))) Then Response.Write("SELECTED" : Response.Write(""%> ><%=(rsEditRecord.Fields.Item("catid".Value)%></option>
<%
rsEditRecord.MoveNext()
Wend
If (rsEditRecord.CursorType > 0) Then
rsEditRecord.MoveFirst
Else
rsEditRecord.Requery
End If
%>
</select></td>
</tr>
<tr>
<td height="3"></td>
</tr>
<tr>
<td height="11"></td>
</tr>
<tr>
<td height="45" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong><br>
Product Picture</strong></font></td>
<td colspan="7" rowspan="2" valign="top"><p align="left"><font color="#000000" size="2" face="Arial, Helvetica, sans-serif"><strong><font color="#000000" face="Arial, Helvetica, sans-serif">
<input name="product_pic" type="text" id="product_pic" value="<%=(rsEditRecord.Fields.Item("product_pic".Value)%>" size="60">
</font></strong></font><strong><font color="#000000" face="Arial, Helvetica, sans-serif">
</font></strong></p></td>
<td rowspan="3" valign="top"><img src="/<%=(rsEditRecord.Fields.Item("product_pic".Value)%>" alt="" width="100" height="80" align="middle"></td>
<td> </td>
</tr>
<tr>
<td height="18"></td>
</tr>
<tr>
<td height="14"></td>
</tr>
<tr>
<td height="11"></td>
<td colspan="8" rowspan="2" valign="top"><p align="left" class="FormElement">
<textarea name="brief_desc" cols="60" rows="2" id="brief_desc"><%=(rsEditRecord.Fields.Item("brief_desc".Value)%></textarea>
</p></td>
</tr>
<tr>
<td height="79" colspan="2" valign="top" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"><strong>Brief
Description</strong></font></td>
</tr>
<tr>
<td height="11"></td>
<td colspan="8" rowspan="3" valign="top" bgcolor="#F5FDFE"> <p align="left" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"></font>
<textarea name="full_desc" cols="70" rows="12" id="full_desc"><%=(rsEditRecord.Fields.Item("full_desc".Value)%></textarea>
</p></td>
</tr>
<tr>
<td height="78" colspan="2" valign="top" class="FormElement"><font color="#000033" face="Arial, Helvetica, sans-serif"><strong>Full
Description</strong></font></td>
</tr>
<tr>
<td height="143"> </td>
<td> </td>
</tr>
<tr>
<td height="30" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Specs
Title</strong></font></td>
<td colspan="8" valign="top"><input name="specs_title" type="text" id="specs_title" value="<%= rsEditRecord.Fields.Item("specs_title".Value %>" size="50">
<font size="2"> Custom heading</font></td>
</tr>
<tr>
<td height="138" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Specifications</strong></font></td>
<td colspan="8" valign="top"><textarea name="specs" cols="50" rows="7" id="specs"><%= rsEditRecord.Fields.Item("specs".Value %></textarea></td>
</tr>
<tr>
<td height="37" colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
1 Name</strong></font></td>
<td colspan="3" valign="top"><input name="brochure1_name" type="text" id="brochure1_name" value="<%= rsEditRecord.Fields.Item("brochure1_name".Value %>" size="30"></td>
<td colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
1 Type</strong></font></td>
<td valign="top"><select name="brochure1_type" id="brochure1_type">
<option value="empty.jpg" <%If (Not isNull((rsEditRecord.Fields.Item("brochure1_type".Value))) Then If ("empty.jpg" = CStr((rsEditRecord.Fields.Item("brochure1_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>NONE
</option>
<option value="images/SITE/pdf.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure1_type".Value))) Then If ("images/SITE/pdf.gif" = CStr((rsEditRecord.Fields.Item("brochure1_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Adobe.pdf
</option>
<option value="images/SITE/word.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure1_type".Value))) Then If ("images/SITE/word.gif" = CStr((rsEditRecord.Fields.Item("brochure1_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Word.doc
</option>
<option value="images/SITE/excel.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure1_type".Value))) Then If ("images/SITE/excel.gif" = CStr((rsEditRecord.Fields.Item("brochure1_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Excel.xls
</option>
</select></td>
<td> </td>
</tr>
<tr>
<td height="37" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
1 File</strong></font></td>
<td colspan="8" valign="top"><input name="brochure1" type="text" id="brochure1" value="<%= rsEditRecord.Fields.Item("brochure1".Value %>" size="80"></td>
<td> </td>
</tr>
<tr>
<td height="11"></td>
</tr>
<tr>
<td height="37" colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
2 Name</strong></font></td>
<td colspan="3" valign="top"><input name="brochure2_name" type="text" id="brochure2_name" value="<%= rsEditRecord.Fields.Item("brochure2_name".Value %>" size="30"></td>
<td colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
2 Type</strong></font></td>
<td valign="top"><select name="brochure2_type" id="select3">
<option value="empty.jpg" <%If (Not isNull((rsEditRecord.Fields.Item("brochure2_type".Value))) Then If ("empty.jpg" = CStr((rsEditRecord.Fields.Item("brochure2_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>NONE
</option>
<option value="images/SITE/pdf.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure2_type".Value))) Then If ("images/SITE/pdf.gif" = CStr((rsEditRecord.Fields.Item("brochure2_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Adobe.pdf
</option>
<option value="images/SITE/word.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure2_type".Value))) Then If ("images/SITE/word.gif" = CStr((rsEditRecord.Fields.Item("brochure2_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Word.doc
</option>
<option value="images/SITE/excel.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure2_type".Value))) Then If ("images/SITE/excel.gif" = CStr((rsEditRecord.Fields.Item("brochure2_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Excel.xls
</option>
</select></td>
</tr>
<tr>
<td height="36" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
2 File</strong></font></td>
<td colspan="8" valign="top"><input name="brochure2" type="text" id="brochure2" value="<%= rsEditRecord.Fields.Item("brochure2".Value %>" size="80"></td>
<td></td>
</tr>
<tr>
<td height="11"></td>
</tr>
<tr>
<td height="37" colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
3 Name</strong></font></td>
<td colspan="3" valign="top"><input name="brochure3_name" type="text" id="brochure3_name" value="<%= rsEditRecord.Fields.Item("brochure3_name".Value %>" size="30"></td>
<td colspan="3" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
3 Type</strong></font></td>
<td valign="top"><select name="brochure3_type" id="select4">
<option value="empty.jpg" <%If (Not isNull((rsEditRecord.Fields.Item("brochure3_type".Value))) Then If ("empty.jpg" = CStr((rsEditRecord.Fields.Item("brochure3_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>NONE
</option>
<option value="images/SITE/pdf.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure3_type".Value))) Then If ("images/SITE/pdf.gif" = CStr((rsEditRecord.Fields.Item("brochure3_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Adobe.pdf
</option>
<option value="images/SITE/word.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure3_type".Value))) Then If ("images/SITE/word.gif" = CStr((rsEditRecord.Fields.Item("brochure3_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Word.doc
</option>
<option value="images/SITE/excel.gif" <%If (Not isNull((rsEditRecord.Fields.Item("brochure3_type".Value))) Then If ("images/SITE/excel.gif" = CStr((rsEditRecord.Fields.Item("brochure3_type".Value))) Then Response.Write("SELECTED" : Response.Write(""%>>Excel.xls
</option>
</select></td>
<td></td>
</tr>
<tr>
<td height="36" colspan="2" valign="top"><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Brochure
3 File</strong></font></td>
<td colspan="8" valign="top"><input name="brochure3" type="text" id="brochure3" value="<%= rsEditRecord.Fields.Item("brochure3".Value %>" size="80"></td>
<td> </td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td height="9"></td>
<td rowspan="2" valign="top" class="Edit-Delete-FORM"> <p align="left"><font color="#000033" size="2">Detail
Pic 1</font></p></td>
</tr>
<tr>
<td height="27"> </td>
<td colspan="8" valign="top"><input name="pic_1" type="text" id="pic_1" value="<%=(rsEditRecord.Fields.Item("pic_1".Value)%>" size="70"></td>
<td></td>
</tr>
<tr>
<td height="96" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td colspan="8" valign="top"><p><img src="/<%=(rsEditRecord.Fields.Item("pic_1".Value)%>" alt="" align="left"></p>
<p> </p>
<p> </p></td>
<td> </td>
</tr>
<tr>
<td height="10"></td>
<td rowspan="2" valign="top"> <p align="left"><font color="#000033" size="2"><strong>Detail
Pic 2</strong></font></p></td>
</tr>
<tr>
<td height="26"></td>
<td colspan="8" valign="top"><input name="pic_2" type="text" id="pic_22" value="<%=(rsEditRecord.Fields.Item("pic_2".Value)%>" size="70"></td>
<td> </td>
</tr>
<tr>
<td height="86" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td colspan="8" valign="top"><p><img src="/<%=(rsEditRecord.Fields.Item("pic_2".Value)%>" alt=""></p>
<p> </p></td>
<td></td>
</tr>
<tr>
<td height="11"></td>
<td rowspan="2" valign="top" bgcolor="#F5FDFE"> <p align="left"><font color="#000066" face="Arial, Helvetica, sans-serif"><strong> </strong></font><font color="#000033" size="2" face="Arial, Helvetica, sans-serif"><strong>Detail
Pic 3</strong></font></p></td>
</tr>
<tr>
<td height="42"></td>
<td colspan="8" valign="top"><font color="#000066" face="Arial, Helvetica, sans-serif"><strong><font color="#000000">
<input name="pic_3" type="text" id="pic_32" value="<%=(rsEditRecord.Fields.Item("pic_3".Value)%>" size="70">
</font></strong></font></td>
<td></td>
</tr>
<tr>
<td height="49" colspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
<td colspan="8" valign="top"><img src="/<%=(rsEditRecord.Fields.Item("pic_3".Value)%>" alt=""></td>
<td> </td>
</tr>
<tr>
<td height="64" colspan="11" valign="top"> <div align="center">
<p> <br>
<input type="submit" name="Submit" value="Edit Product">
</p>
</div></td>
</tr>
</table>
<input type="hidden" name="MM_update" value="Edit">
<input type="hidden" name="MM_recordId" value="<%= rsEditRecord.Fields.Item("ID".Value %>">
</div>
</form>
<p align="center" class="style1"><a href="javascript:history.go(-1)"><font color="#000066" size="3" face="Arial, Helvetica, sans-serif"><<
BACK</font></a></p>
</div>
</body>
</html>
<%
rsEditRecord.Close()
Set rsEditRecord = Nothing
%>
------------------------------------------------------------------------------------
Please somebody take out of this den of inequity!! <img src=../images/dmxzone/forum/icon_smile_sad.gif border=0 align=middle>