keeper3
asked on
Removing 1 of 2 url parameters after inserting a record
Situation is, I have a detail page (vendor_detail.asp) for a particular vendor, displaying all of his equipment. This page has an existing url parameter for the vendor's specific id (vendor_id) so that only his equipment is displayed. You can click on each piece of equipment to go and edit the details of that equipment (equip_edit.asp). Currently, when you click on the equipment piece, it will create a new url parameter(equip_id) so that the edit page only displays that piece of equipement for editing. Additionally, I am passing the existing url parameter of vendor_id so that I can pass it back after submitting the edit equipment (and return to the same vendor_detail.asp page).
My problem is that after submitting the updated equipment record, it is passing back both url parameters (vendor_id and equip_id). This is a problem if I want to edit the equipment detail again as it will now have 3 url parameters (vendor_id and 2 equip_id's), and errors out the page, message included for giggles.
ADODB.Recordset.1 error '80004005'
SQLState: 42000
Native Error Code: 1064
[TCX][MyODBC]You have an error in your SQL syntax near ' 2' at line 1
I am using the built in functionality of Dreamweaver for "Go to Detail Page".
I guess my question has a couple parts:
a) I don't remember specifying in the first place that the equip_edit.asp should pass url parameters back after submitting the update record. Is this a default when using the "update record" behavior?
b) How can you selectively pass back url parameters? I don't see this as built in to dreamweaver. The only url parameter I want to pass back is the vendor_id one.
I have relatively meager hand coding skills, though I can certainly follow directions like a champ.
Any help here would be appreciated.
Thanks
My problem is that after submitting the updated equipment record, it is passing back both url parameters (vendor_id and equip_id). This is a problem if I want to edit the equipment detail again as it will now have 3 url parameters (vendor_id and 2 equip_id's), and errors out the page, message included for giggles.
ADODB.Recordset.1 error '80004005'
SQLState: 42000
Native Error Code: 1064
[TCX][MyODBC]You have an error in your SQL syntax near ' 2' at line 1
I am using the built in functionality of Dreamweaver for "Go to Detail Page".
I guess my question has a couple parts:
a) I don't remember specifying in the first place that the equip_edit.asp should pass url parameters back after submitting the update record. Is this a default when using the "update record" behavior?
b) How can you selectively pass back url parameters? I don't see this as built in to dreamweaver. The only url parameter I want to pass back is the vendor_id one.
I have relatively meager hand coding skills, though I can certainly follow directions like a champ.
Any help here would be appreciated.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Code is below, apologies for the delay... I tried to cut out the stuff that was irrelevant, but there still a good bit. For reference, there are two url parameters that are getting passed to this asp page, "vendor_id" and "resis_id". After I do the submit to delete the record (or edit, I have the same issue with both), both parameters are getting bassed back to the redirect page after the submission. I would only like to pass back one, the "vendor_id" parameter. Thanks for any help, John.
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<%
// *** Edit Operations: declare variables
// set the form action variable
var MM_editAction = Request.ServerVariables("S CRIPT_NAME ");
if (Request.QueryString) {
MM_editAction += "?" + Request.QueryString;
}
// boolean to abort record edit
var MM_abortEdit = false;
// query string to execute
var MM_editQuery = "";
%>
<%
// *** Delete Record: declare variables
if (String(Request("MM_delete ")) == "form1" &&
String(Request("MM_recordI d")) != "undefined") {
var MM_editConnection = MM_hosted_auburn_STRING;
var MM_editTable = "resis_data";
var MM_editColumn = "resis_id";
var MM_recordId = "" + Request.Form("MM_recordId" ) + "";
var MM_editRedirectUrl = "resis_list.asp";
// append the query string to the redirect URL
if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.index Of('?') == -1)?"?":"&") + Request.QueryString;
}
}
%>
<%
// *** Delete Record: construct a sql delete statement and execute it
if (String(Request("MM_delete ")) != "undefined" &&
String(Request("MM_recordI d")) != "undefined") {
// create the sql delete statement
MM_editQuery = "delete from " + MM_editTable + " where " + MM_editColumn + " = " + MM_recordId;
if (!MM_abortEdit) {
// execute the delete
var MM_editCmd = Server.CreateObject('ADODB .Command') ;
MM_editCmd.ActiveConnectio n = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute();
MM_editCmd.ActiveConnectio n.Close();
if (MM_editRedirectUrl) {
Response.Redirect(MM_editR edirectUrl );
}
}
}
%>
<%
var vendor_rec__MMColParam = "1";
if (String(Request.QueryStrin g("vendor_ id")) != "undefined" &&
String(Request.QueryString ("vendor_i d")) != "") {
vendor_rec__MMColParam = String(Request.QueryString ("vendor_i d"));
}
%>
<%
var vendor_rec = Server.CreateObject("ADODB .Recordset ");
vendor_rec.ActiveConnectio n = MM_hosted_auburn_STRING;
vendor_rec.Source = "SELECT vendor_id, vendor_name FROM vendor_data WHERE vendor_id = "+ vendor_rec__MMColParam.rep lace(/'/g, "''") + "";
vendor_rec.CursorType = 0;
vendor_rec.CursorLocation = 2;
vendor_rec.LockType = 1;
vendor_rec.Open();
var vendor_rec_numRows = 0;
%>
<%
var resis_rec__MMColParam = "1";
if (String(Request.QueryStrin g("resis_i d")) != "undefined" &&
String(Request.QueryString ("resis_id ")) != "") {
resis_rec__MMColParam = String(Request.QueryString ("resis_id "));
}
%>
<%
var resis_rec = Server.CreateObject("ADODB .Recordset ");
resis_rec.ActiveConnection = MM_hosted_auburn_STRING;
resis_rec.Source = "SELECT r.*,r.watts*r.qty*r.h_w/10 00*4.33*ec .kwh_cost as resis_op FROM resis_data r,elec_cost ec WHERE resis_id = "+ resis_rec__MMColParam.repl ace(/'/g, "''") + "";
resis_rec.CursorType = 0;
resis_rec.CursorLocation = 2;
resis_rec.LockType = 1;
resis_rec.Open();
var resis_rec_numRows = 0;
%>
<% var MM_paramName = ""; %>
<%
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
// create the list of parameters which should not be maintained
var MM_removeList = "&index=";
if (MM_paramName != "") MM_removeList += "&" + MM_paramName.toLowerCase() + "=";
var MM_keepURL="",MM_keepForm= "",MM_keep Both="",MM _keepNone= "";
// add the URL parameters to the MM_keepURL string
for (var items=new Enumerator(Request.QuerySt ring); !items.atEnd(); items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nex tItem) == -1) {
MM_keepURL += "&" + items.item() + "=" + Server.URLencode(Request.Q ueryString (items.ite m()));
}
}
// add the Form variables to the MM_keepForm string
for (var items=new Enumerator(Request.Form); !items.atEnd(); items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase() + "=";
if (MM_removeList.indexOf(nex tItem) == -1) {
MM_keepForm += "&" + items.item() + "=" + Server.URLencode(Request.F orm(items. item()));
}
}
// create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL + MM_keepForm;
if (MM_keepBoth.length > 0) MM_keepBoth = MM_keepBoth.substring(1);
if (MM_keepURL.length > 0) MM_keepURL = MM_keepURL.substring(1);
if (MM_keepForm.length > 0) MM_keepForm = MM_keepForm.substring(1);
%>
<html>
<head>
<
<p>
<input name="Submit" type="submit" onClick="MM_validateForm(' textfield2 ','','R',' textfield3 ','','RisN um','textf ield4','', 'RisNum',' textfield5 ','','NisN um','textf ield6','', 'RisNum'); return document.MM_returnValue" value="Delete?">
<a href="resis_list.asp?<%= MM_keepNone + ((MM_keepNone!="")?"&":"") + "vendor_id=" + resis_rec.Fields.Item("ven dor_id").V alue %>">Cancel
and Return to Vendor Detail</a> </p>
<p> </p>
<p><IMG SRC="charts/resis_single.a sp?<%= MM_keepURL %>">
</p>
<p> </p>
<input type="hidden" name="MM_delete" value="form1">
<input type="hidden" name="MM_recordId" value="<%= resis_rec.Fields.Item("res is_id").Va lue %>">
</form>
<p> </p>
</body>
</html>
<%
vendor_rec.Close();
%>
<%
resis_rec.Close();
%>
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<%
// *** Edit Operations: declare variables
// set the form action variable
var MM_editAction = Request.ServerVariables("S
if (Request.QueryString) {
MM_editAction += "?" + Request.QueryString;
}
// boolean to abort record edit
var MM_abortEdit = false;
// query string to execute
var MM_editQuery = "";
%>
<%
// *** Delete Record: declare variables
if (String(Request("MM_delete
String(Request("MM_recordI
var MM_editConnection = MM_hosted_auburn_STRING;
var MM_editTable = "resis_data";
var MM_editColumn = "resis_id";
var MM_recordId = "" + Request.Form("MM_recordId"
var MM_editRedirectUrl = "resis_list.asp";
// append the query string to the redirect URL
if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.index
}
}
%>
<%
// *** Delete Record: construct a sql delete statement and execute it
if (String(Request("MM_delete
String(Request("MM_recordI
// create the sql delete statement
MM_editQuery = "delete from " + MM_editTable + " where " + MM_editColumn + " = " + MM_recordId;
if (!MM_abortEdit) {
// execute the delete
var MM_editCmd = Server.CreateObject('ADODB
MM_editCmd.ActiveConnectio
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute();
MM_editCmd.ActiveConnectio
if (MM_editRedirectUrl) {
Response.Redirect(MM_editR
}
}
}
%>
<%
var vendor_rec__MMColParam = "1";
if (String(Request.QueryStrin
String(Request.QueryString
vendor_rec__MMColParam = String(Request.QueryString
}
%>
<%
var vendor_rec = Server.CreateObject("ADODB
vendor_rec.ActiveConnectio
vendor_rec.Source = "SELECT vendor_id, vendor_name FROM vendor_data WHERE vendor_id = "+ vendor_rec__MMColParam.rep
vendor_rec.CursorType = 0;
vendor_rec.CursorLocation = 2;
vendor_rec.LockType = 1;
vendor_rec.Open();
var vendor_rec_numRows = 0;
%>
<%
var resis_rec__MMColParam = "1";
if (String(Request.QueryStrin
String(Request.QueryString
resis_rec__MMColParam = String(Request.QueryString
}
%>
<%
var resis_rec = Server.CreateObject("ADODB
resis_rec.ActiveConnection
resis_rec.Source = "SELECT r.*,r.watts*r.qty*r.h_w/10
resis_rec.CursorType = 0;
resis_rec.CursorLocation = 2;
resis_rec.LockType = 1;
resis_rec.Open();
var resis_rec_numRows = 0;
%>
<% var MM_paramName = ""; %>
<%
// *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
// create the list of parameters which should not be maintained
var MM_removeList = "&index=";
if (MM_paramName != "") MM_removeList += "&" + MM_paramName.toLowerCase()
var MM_keepURL="",MM_keepForm=
// add the URL parameters to the MM_keepURL string
for (var items=new Enumerator(Request.QuerySt
var nextItem = "&" + items.item().toLowerCase()
if (MM_removeList.indexOf(nex
MM_keepURL += "&" + items.item() + "=" + Server.URLencode(Request.Q
}
}
// add the Form variables to the MM_keepForm string
for (var items=new Enumerator(Request.Form); !items.atEnd(); items.moveNext()) {
var nextItem = "&" + items.item().toLowerCase()
if (MM_removeList.indexOf(nex
MM_keepForm += "&" + items.item() + "=" + Server.URLencode(Request.F
}
}
// create the Form + URL string and remove the intial '&' from each of the strings
MM_keepBoth = MM_keepURL + MM_keepForm;
if (MM_keepBoth.length > 0) MM_keepBoth = MM_keepBoth.substring(1);
if (MM_keepURL.length > 0) MM_keepURL = MM_keepURL.substring(1);
if (MM_keepForm.length > 0) MM_keepForm = MM_keepForm.substring(1);
%>
<html>
<head>
<
<p>
<input name="Submit" type="submit" onClick="MM_validateForm('
<a href="resis_list.asp?<%= MM_keepNone + ((MM_keepNone!="")?"&":"")
and Return to Vendor Detail</a> </p>
<p> </p>
<p><IMG SRC="charts/resis_single.a
</p>
<p> </p>
<input type="hidden" name="MM_delete" value="form1">
<input type="hidden" name="MM_recordId" value="<%= resis_rec.Fields.Item("res
</form>
<p> </p>
</body>
</html>
<%
vendor_rec.Close();
%>
<%
resis_rec.Close();
%>
ASKER
One more thought. What's wrong with the below code? This should work, as I get the behavior I want (only one url parameter, vendor_id) when I setup a hyperlink this way, but I can't get the redirect url to use this. Pardon my ignorance on this... Thanks.
var MM_editRedirectUrl = "resis_list.asp" + <%= MM_keepNone + ((MM_keepNone!="")?"&":"") + "vendor_id=" + resis_rec.Fields.Item("ven dor_id").V alue %>;
I get a error of
Error Type:
Microsoft JScript compilation (0x800A03EA)
Syntax error
on the line.
var MM_editRedirectUrl = "resis_list.asp" + <%= MM_keepNone + ((MM_keepNone!="")?"&":"")
I get a error of
Error Type:
Microsoft JScript compilation (0x800A03EA)
Syntax error
on the line.
Zombeen