Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting an individual record from drop-down menu

Status
Not open for further replies.

paul1980

Technical User
Aug 8, 2001
2
GB
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=&quot;get_name&quot; DATASOURCE=&quot;register2&quot;>
SELECT * FROM masterclass
</CFQUERY>

<CFQUERY NAME=&quot;get_building&quot; DATASOURCE=&quot;register2&quot;>
SELECT * FROM dates
WHERE m_id = #m_id#
</CFQUERY>

<CFQUERY NAME=&quot;get_mnum&quot; DATASOURCE=&quot;register2&quot;>
SELECT * from masterclass
WHERE m_id = #m_id#
</CFQUERY>

<CFQUERY NAME=&quot;get_people&quot; DATASOURCE=&quot;register2&quot;>
SELECT * FROM bookings
WHERE id_number = '#id_number#' AND confirmed='y'
</CFQUERY>

<html>

<head>
<title>Home Page</title>
<script LANGUAGE=&quot;JavaScript&quot;>
<!--

function openAnyWindow(url, name) {
var l = openAnyWindow.arguments.length;
var w = &quot;&quot;;
var h = &quot;&quot;;
var features = &quot;&quot;;

for (i=2; i<l; i++) {
var param = openAnyWindow.arguments;
if ( (parseInt(param) == 0) ||
(isNaN(parseInt(param))) ) {
features += param + ',';
} else {
(w == &quot;&quot;) ? w = &quot;width=&quot; + param + &quot;,&quot; :
h = &quot;height=&quot; + param;
}
}

features += w + h;
var code = &quot;popupWin = window.open(url, name&quot;;
if (l > 2) code += &quot;, '&quot; + features;
code += &quot;')&quot;;
eval(code);
}
//-->
</script>

</head>

<body bgcolor=&quot;white&quot;>

<BIG>
<BIG>
<p align=&quot;center&quot;><font face=&quot;Comic Sans MS&quot; color=&quot;blue&quot;>Remove your reservation from a Masterclass</FONT></p>
<P><P></BIG></BIG>

<a
href=&quot;javascript:eek:penAnyWindow(' align =&quot;right&quot;><big><font
face=&quot;Comic Sans MS&quot; color=&quot;#0000A0&quot;>HELP</font></big></a></big></p>

<font face=&quot;Comic Sans MS&quot; color=&quot;blue&quot;>1. Select the name of your Masterclass from the 1st dropdown menu, and click on &quot;Get Location List&quot;</FONT><BR>
<font face=&quot;Comic Sans MS&quot; color=&quot;blue&quot;>2. Select the Date and Location from the second dropdown menu, and then click on &quot;View Attendance List&quot;</FONT><BR>
<font face=&quot;Comic Sans MS&quot; color=&quot;blue&quot;>3. Select your details from the drop-down list<BR>
<font face=&quot;Comic Sans MS&quot; color=&quot;blue&quot;>4. Finally, once you have found your details, click on the &quot;Delete Information&quot; button to remove yourself from the attendance list<BR><BR>
<font face=&quot;Comic Sans MS&quot; color=&quot;blue&quot;> 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=&quot;POST&quot; action=&quot;delete_indiv_sess.cfm&quot;>

<p>
1:
<select name=&quot;m_id&quot; size=&quot;1&quot;>
<CFOUTPUT QUERY=&quot;get_name&quot;>
<option value=&quot;#m_id#&quot;>#m_name#</option>
</CFOUTPUT>
</select>
<br>
<input type=&quot;hidden&quot; name=&quot;id_number&quot; value=&quot;0&quot;>
<input type=&quot;submit&quot; value=&quot;Get Location List&quot; name=&quot;B1&quot;></p>
</form>

<hr>
<form>
<p>
2:
<select name=&quot;id_number&quot; size=&quot;1&quot;>
<CFOUTPUT QUERY=&quot;get_building&quot;>
<option value=&quot;#id_number#&quot;>#building#.........#dateformat(&quot;#tdate#&quot;,&quot;dd/mmm/yyyy&quot;)#</option>
</CFOUTPUT>
</select>
<br>

<CFOUTPUT QUERY=&quot;get_mnum&quot;>
<input type=&quot;hidden&quot; name=&quot;m_id&quot; value=&quot;#m_id#&quot;>
<input type=&quot;submit&quot; value=&quot;View attendance list&quot; name=&quot;B1&quot;></p>
</CFOUTPUT>
<hr>
</font>
</form>

<form>
<p>
3:
<select name=&quot;id_number&quot; size=&quot;1&quot;>
<CFOUTPUT QUERY=&quot;get_people&quot;>
<option value=&quot;#id_number#&quot;>#u_name#.........#Registered#</option>
</CFOUTPUT>
</select>
<br>

</p>
</form>

4:
<CFOUTPUT QUERY=&quot;get_mnum&quot;>
<form method=&quot;POST&quot; action=&quot;delete_indiv_sess2.cfm&quot;>
</CFOUTPUT>
<CFOUTPUT QUERY=&quot;get_mnum&quot;>
<input type=&quot;hidden&quot; NAME=&quot;m_id&quot; value=&quot;#m_id#&quot;>
<input type=&quot;submit&quot; name=&quot;b1&quot; value=&quot;Delete Information&quot;>
</CFOUTPUT>

<P><P align=&quot;center&quot;>
<font face=&quot;Comic Sans MS&quot; color=&quot;blue&quot;><a href=&quot; Click here to go back</a></FONT>
</body>
</html>

</body>
</html>
---------------------------------------------------------
//delete_indiv_sess2.cfm

<CFQUERY NAME=&quot;delete&quot; DATASOURCE=&quot;register2&quot;>
DELETE FROM bookings
WHERE id_number = #id_number#
</CFQUERY>

<HTML>
<HEAD>
<TITLE>Thanks!</TITLE>
</HEAD>

<BODY bgcolor=&quot;white&quot;>
<font face=&quot;Comic Sans MS&quot; color=&quot;blue&quot; align=&quot;center&quot;>
<HR>
<P>

<H3>Your Masterclass reservation has now been cancelled!</H3></P>
<hr>
<P><P align=&quot;center&quot;>
<font face=&quot;Comic Sans MS&quot; color=&quot;blue&quot;><a href=&quot;javascript:history.go(-1)&quot;> Click here to go back</a></FONT>


</BODY>
</HTML>
 
Hi Paul,

That's a lot of code to look through...

I am thinking that what you want to do is delete options from a <select ... > drop down menu?

That is not so hard. Just takes a little javascript.
take a look at this example and see if you can't incorporate it into your application:


<SCRIPT Language=&quot;JavaScript&quot;>
function delselected(form)
{
choice = form.One.selectedIndex;
var count = choice
while (count < form.One.length-1)
{
form.One.options[count].text = form.One.options[count+1].text;
form.One.options[count].value = form.One.options[count+1].value;
count++
}
(form.One.length)--;
}
</script>


<FORM METHOD=&quot;POST&quot; ACTION=&quot;look.cfm&quot; NAME=&quot;myform&quot;>
<SELECT NAME=&quot;One&quot; >
<OPTION VALUE = &quot;1&quot;>Test1</OPTION>
<OPTION VALUE = &quot;2&quot;>Test2</OPTION>
<OPTION VALUE = &quot;3&quot;>Test3</OPTION>
<OPTION VALUE = &quot;4&quot;>Test4</OPTION>
<OPTION VALUE = &quot;5&quot;>Test5</OPTION>
</SELECT>
<input type=&quot;button&quot; name=&quot;Del&quot; value=&quot;delete selected item&quot; onClick = &quot;delselected(this.form)&quot; >
</FORM>

this example is complete if you cut and paste it into a page it will work. It doesn't really require CF at all, it is just javascript (and html).

Let me know if this is really what you were after.
hope it helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top