HELP! I'm new to ColdFusion and am having trying to create code that will allow me to delete a single record from a drop-down list. The problem seems to be with linking the record I have chosen from the drop-down with the delete button.
Please find enclosed the source code which should help in identifying where I am going wrong.
<CFQUERY NAME="get_name" DATASOURCE="register2">
SELECT * FROM masterclass
</CFQUERY>
<CFQUERY NAME="get_building" DATASOURCE="register2">
SELECT * FROM dates
WHERE m_id = #m_id#
</CFQUERY>
<CFQUERY NAME="get_mnum" DATASOURCE="register2">
SELECT * from masterclass
WHERE m_id = #m_id#
</CFQUERY>
<CFQUERY NAME="get_people" DATASOURCE="register2">
SELECT * FROM bookings
WHERE id_number = '#id_number#' AND confirmed='y'
</CFQUERY>
<html>
<head>
<title>Home Page</title>
<script LANGUAGE="JavaScript">
<!--
function openAnyWindow(url, name) {
var l = openAnyWindow.arguments.length;
var w = "";
var h = "";
var features = "";
for (i=2; i<l; i++) {
var param = openAnyWindow.arguments;
if ( (parseInt(param) == 0) ||
(isNaN(parseInt(param))) ) {
features += param + ',';
} else {
(w == "" ? w = "width=" + param + "," :
h = "height=" + param;
}
}
features += w + h;
var code = "popupWin = window.open(url, name";
if (l > 2) code += ", '" + features;
code += "')";
eval(code);
}
//-->
</script>
</head>
<body bgcolor="white">
<BIG>
<BIG>
<p align="center"><font face="Comic Sans MS" color="blue">Remove your reservation from a Masterclass</FONT></p>
<P><P></BIG></BIG>
<a
href="javascriptpenAnyWindow(' align ="right"><big><font
face="Comic Sans MS" color="#0000A0">HELP</font></big></a></big></p>
<font face="Comic Sans MS" color="blue">1. Select the name of your Masterclass from the 1st dropdown menu, and click on "Get Location List"</FONT><BR>
<font face="Comic Sans MS" color="blue">2. Select the Date and Location from the second dropdown menu, and then click on "View Attendance List"</FONT><BR>
<font face="Comic Sans MS" color="blue">3. Select your details from the drop-down list<BR>
<font face="Comic Sans MS" color="blue">4. Finally, once you have found your details, click on the "Delete Information" button to remove yourself from the attendance list<BR><BR>
<font face="Comic Sans MS" color="blue"> NB. After completing options 1 & 2, the values will return to what they were initially! Just ignore this, and proceed with option '3'<br>
<hr>
<form method="POST" action="delete_indiv_sess.cfm">
<p>
1:
<select name="m_id" size="1">
<CFOUTPUT QUERY="get_name">
<option value="#m_id#">#m_name#</option>
</CFOUTPUT>
</select>
<br>
<input type="hidden" name="id_number" value="0">
<input type="submit" value="Get Location List" name="B1"></p>
</form>
<hr>
<form>
<p>
2:
<select name="id_number" size="1">
<CFOUTPUT QUERY="get_building">
<option value="#id_number#">#building#.........#dateformat("#tdate#","dd/mmm/yyyy"#</option>
</CFOUTPUT>
</select>
<br>
<CFOUTPUT QUERY="get_mnum">
<input type="hidden" name="m_id" value="#m_id#">
<input type="submit" value="View attendance list" name="B1"></p>
</CFOUTPUT>
<hr>
</font>
</form>
<form>
<p>
3:
<select name="id_number" size="1">
<CFOUTPUT QUERY="get_people">
<option value="#id_number#">#u_name#.........#Registered#</option>
</CFOUTPUT>
</select>
<br>
</p>
</form>
4:
<CFOUTPUT QUERY="get_mnum">
<form method="POST" action="delete_indiv_sess2.cfm">
</CFOUTPUT>
<CFOUTPUT QUERY="get_mnum">
<input type="hidden" NAME="m_id" value="#m_id#">
<input type="submit" name="b1" value="Delete Information">
</CFOUTPUT>
<P><P align="center">
<font face="Comic Sans MS" color="blue"><a href=" Click here to go back</a></FONT>
</body>
</html>
</body>
</html>
---------------------------------------------------------
//delete_indiv_sess2.cfm
<CFQUERY NAME="delete" DATASOURCE="register2">
DELETE FROM bookings
WHERE id_number = #id_number#
</CFQUERY>
<HTML>
<HEAD>
<TITLE>Thanks!</TITLE>
</HEAD>
<BODY bgcolor="white">
<font face="Comic Sans MS" color="blue" align="center">
<HR>
<P>
<H3>Your Masterclass reservation has now been cancelled!</H3></P>
<hr>
<P><P align="center">
<font face="Comic Sans MS" color="blue"><a href="javascript:history.go(-1)"> Click here to go back</a></FONT>
</BODY>
</HTML>
Please find enclosed the source code which should help in identifying where I am going wrong.
<CFQUERY NAME="get_name" DATASOURCE="register2">
SELECT * FROM masterclass
</CFQUERY>
<CFQUERY NAME="get_building" DATASOURCE="register2">
SELECT * FROM dates
WHERE m_id = #m_id#
</CFQUERY>
<CFQUERY NAME="get_mnum" DATASOURCE="register2">
SELECT * from masterclass
WHERE m_id = #m_id#
</CFQUERY>
<CFQUERY NAME="get_people" DATASOURCE="register2">
SELECT * FROM bookings
WHERE id_number = '#id_number#' AND confirmed='y'
</CFQUERY>
<html>
<head>
<title>Home Page</title>
<script LANGUAGE="JavaScript">
<!--
function openAnyWindow(url, name) {
var l = openAnyWindow.arguments.length;
var w = "";
var h = "";
var features = "";
for (i=2; i<l; i++) {
var param = openAnyWindow.arguments;
if ( (parseInt(param) == 0) ||
(isNaN(parseInt(param))) ) {
features += param + ',';
} else {
(w == "" ? w = "width=" + param + "," :
h = "height=" + param;
}
}
features += w + h;
var code = "popupWin = window.open(url, name";
if (l > 2) code += ", '" + features;
code += "')";
eval(code);
}
//-->
</script>
</head>
<body bgcolor="white">
<BIG>
<BIG>
<p align="center"><font face="Comic Sans MS" color="blue">Remove your reservation from a Masterclass</FONT></p>
<P><P></BIG></BIG>
<a
href="javascriptpenAnyWindow(' align ="right"><big><font
face="Comic Sans MS" color="#0000A0">HELP</font></big></a></big></p>
<font face="Comic Sans MS" color="blue">1. Select the name of your Masterclass from the 1st dropdown menu, and click on "Get Location List"</FONT><BR>
<font face="Comic Sans MS" color="blue">2. Select the Date and Location from the second dropdown menu, and then click on "View Attendance List"</FONT><BR>
<font face="Comic Sans MS" color="blue">3. Select your details from the drop-down list<BR>
<font face="Comic Sans MS" color="blue">4. Finally, once you have found your details, click on the "Delete Information" button to remove yourself from the attendance list<BR><BR>
<font face="Comic Sans MS" color="blue"> NB. After completing options 1 & 2, the values will return to what they were initially! Just ignore this, and proceed with option '3'<br>
<hr>
<form method="POST" action="delete_indiv_sess.cfm">
<p>
1:
<select name="m_id" size="1">
<CFOUTPUT QUERY="get_name">
<option value="#m_id#">#m_name#</option>
</CFOUTPUT>
</select>
<br>
<input type="hidden" name="id_number" value="0">
<input type="submit" value="Get Location List" name="B1"></p>
</form>
<hr>
<form>
<p>
2:
<select name="id_number" size="1">
<CFOUTPUT QUERY="get_building">
<option value="#id_number#">#building#.........#dateformat("#tdate#","dd/mmm/yyyy"#</option>
</CFOUTPUT>
</select>
<br>
<CFOUTPUT QUERY="get_mnum">
<input type="hidden" name="m_id" value="#m_id#">
<input type="submit" value="View attendance list" name="B1"></p>
</CFOUTPUT>
<hr>
</font>
</form>
<form>
<p>
3:
<select name="id_number" size="1">
<CFOUTPUT QUERY="get_people">
<option value="#id_number#">#u_name#.........#Registered#</option>
</CFOUTPUT>
</select>
<br>
</p>
</form>
4:
<CFOUTPUT QUERY="get_mnum">
<form method="POST" action="delete_indiv_sess2.cfm">
</CFOUTPUT>
<CFOUTPUT QUERY="get_mnum">
<input type="hidden" NAME="m_id" value="#m_id#">
<input type="submit" name="b1" value="Delete Information">
</CFOUTPUT>
<P><P align="center">
<font face="Comic Sans MS" color="blue"><a href=" Click here to go back</a></FONT>
</body>
</html>
</body>
</html>
---------------------------------------------------------
//delete_indiv_sess2.cfm
<CFQUERY NAME="delete" DATASOURCE="register2">
DELETE FROM bookings
WHERE id_number = #id_number#
</CFQUERY>
<HTML>
<HEAD>
<TITLE>Thanks!</TITLE>
</HEAD>
<BODY bgcolor="white">
<font face="Comic Sans MS" color="blue" align="center">
<HR>
<P>
<H3>Your Masterclass reservation has now been cancelled!</H3></P>
<hr>
<P><P align="center">
<font face="Comic Sans MS" color="blue"><a href="javascript:history.go(-1)"> Click here to go back</a></FONT>
</BODY>
</HTML>