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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update drop down list example?

Status
Not open for further replies.

longmatch

Programmer
Nov 1, 2001
406
I have two dropdown comboboxes in my ASP form, one is dependent on the other. The data is from MS access database. I just want to add a page to allow user to update the items in the database such as 'add', 'modify' and'delete'. Does anyone have this kind of examples?

Thanks

Longmatch
 
It is possible to create an add, update and delete setup on one asp script, using a hidden form variable to control the script status. Do you want the add, update and delete options visable on the page with the drop downs or as a seperate option.

If you want to email me with your drop down script and a brief explenation of what you want and I'll put something together for you.

barry.bks@jesus-internet.co.uk



Barry

ICT Network Administrator
IT Services Manager
 
Dear BarryMVS:
Thank you for your help. I just finished coding this program. The problem is solved, but not sure whether it is the best way to do it. This code is just used to modify the single combo box in the backend database. I thought the logic should be the same for updating linked combo box data.

Please review my code, give you your suggestion.

Have a good weekend.

Longmatch

<!--#include file=&quot;connection.asp&quot;-->
<%
dim rsRotation, strQryRotation
set rsRotation = Server.CreateObject(&quot;ADODB.Recordset&quot;)
strQryRotation =&quot;SELECT * FROM rotation;&quot;
rsRotation.open strQryRotation, objConn, 2, 2

Select CASE LCase(Trim(Request.QueryString(&quot;action&quot;)))
case &quot;addsave&quot;
dim rsAddRotation, strQryAddRotation
set rsAddRotation = Server.CreateObject(&quot;ADODB.Recordset&quot;)
strQryAddRotation =&quot;SELECT * FROM rotation;&quot;
rsAddRotation.open strQryAddRotation, objConn, 2, 2

rsAddRotation.addnew
rsAddRotation(&quot;rotation&quot;)=request(&quot;rotation&quot;)
rsAddRotation(&quot;NewAbbr&quot;)= request(&quot;abbr&quot;)
rsAddRotation.update

rsAddRotation.close
set rsAddRotation = nothing
case &quot;edit&quot;
dim rsEditRotation, strQryEditRotation
set rsEditRotation = Server.CreateObject(&quot;ADODB.Recordset&quot;)
strQryEditRotation =&quot;SELECT * FROM rotation WHERE ID=&quot; & request(&quot;ID&quot;)
rsEditRotation.open strQryEditRotation, objConn, 2, 2
case &quot;editsave&quot;
dim rsEditsaveRotation, strQryEditsaveRotation
set rsEditsaveRotation = Server.CreateObject(&quot;ADODB.Recordset&quot;)
strQryEditsaveRotation =&quot;SELECT * FROM rotation WHERE ID=&quot; & request(&quot;ID&quot;)
response.write strQryEditsaveRotation
rsEditsaveRotation.open strQryEditsaveRotation, objConn, 2, 2

rsEditsaveRotation(&quot;rotation&quot;)=request(&quot;rotation&quot;)
rsEditsaveRotation(&quot;NewAbbr&quot;)= request(&quot;abbr&quot;)
rsEditsaveRotation.update
case &quot;delete&quot;
dim rsDeleteRotation, strQryDeleteRotation
set rsDeleteRotation = Server.CreateObject(&quot;ADODB.Recordset&quot;)
strQryDeleteRotation =&quot;DELETE FROM rotation WHERE ID=&quot; & request(&quot;ID&quot;)
rsDeleteRotation.open strQryDeleteRotation, objConn, 2, 2

rsDeleteRotation.close
set rsDeleteRotation = nothing
end Select




%>
<!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;>
<html><!-- InstanceBegin template=&quot;/Templates/baylor_Template.dwt&quot; codeOutsideHTMLIsLocked=&quot;false&quot; -->
<head>
<!-- InstanceBeginEditable name=&quot;doctitle&quot; -->
<title>Baylor College of Medicine</title>
<!-- InstanceEndEditable -->
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<!-- InstanceBeginEditable name=&quot;head&quot; --><!-- InstanceEndEditable -->
</head>
<link href=&quot;file:///C|/Documents%20and%20Settings/csc-student/Local%20Settings/bcm_depts.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>
<body leftmargin=&quot;0&quot; topmargin=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; bgcolor=&quot;#FFFFFF&quot;>
<table width=&quot;760&quot; border=&quot;0&quot; align=&quot;left&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>
<tr bgcolor=&quot;white&quot;>
<td>
<!-- header table -->
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;760&quot;>
<tr>
<td><a href=&quot; name=&quot;logo&quot; src=&quot;images/logo.gif&quot; width=&quot;157&quot; height=&quot;118&quot; border=&quot;0&quot; alt=&quot;Baylor College of Medicine&quot;></a></td>
<td><a href=&quot;images/department.gif&quot;><img name=&quot;department&quot; src=&quot;images/department.gif&quot; width=&quot;603&quot; height=&quot;118&quot; border=&quot;0&quot; alt=&quot;&quot;></a></td>
</tr>
</table></td>
</tr>
<tr>
<td>
<table border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; width=&quot;760&quot;>
<tr>
<td width=&quot;157&quot; align=&quot;left&quot; valign=&quot;top&quot; bgcolor=&quot;9999cc&quot;><a href=&quot;images/092802_r2_c1.gif&quot;><img name=&quot;n092802_r2_c1&quot; src=&quot;images/092802_r2_c1.gif&quot; width=&quot;157&quot; height=&quot;30&quot; border=&quot;0&quot; alt=&quot;&quot;></a>
<table width=&quot;100%&quot; border=&quot;0&quot; align=&quot;left&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot;>
<tr>
<td width=&quot;24&quot; align=&quot;left&quot; valign=&quot;top&quot;><img src=&quot;file:///C|/Documents%20and%20Settings/csc-student/Local%20Settings/images/square.gif&quot; width=&quot;24&quot; height=&quot;9&quot;></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width=&quot;24&quot; align=&quot;left&quot; valign=&quot;top&quot;><img src=&quot;file:///C|/Documents%20and%20Settings/csc-student/Local%20Settings/images/square.gif&quot; width=&quot;24&quot; height=&quot;9&quot;></td>
<td valign=&quot;top&quot;><a href=&quot;procedure.asp&quot;>Procedure Form</a></td>
</tr>
<tr>
<td width=&quot;24&quot; align=&quot;left&quot; valign=&quot;top&quot;><img src=&quot;file:///C|/Documents%20and%20Settings/csc-student/Local%20Settings/images/square.gif&quot; width=&quot;24&quot; height=&quot;9&quot;></td>
<td><a href=&quot;ReportByProcedure.asp&quot;><font color=&quot;#0000FF&quot;>view
procedure</font></a></td>
</tr>
<tr>
<td align=&quot;left&quot; valign=&quot;top&quot;>&nbsp;</td>
<td><a href=&quot;RecSearch.asp&quot;>procedure search</a></td>
</tr>
<tr>
<td align=&quot;left&quot; valign=&quot;top&quot;>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>

</td>
<td align=&quot;left&quot; valign=&quot;top&quot;>
<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot; height=&quot;58&quot;>
<tr bgcolor=&quot;white&quot;>
<td height=&quot;51&quot;> <!-- #BeginEditable &quot;contents&quot; -->
<%

If Not rsRotation.EOF Then ' current user has Procedures
Response.Write _
&quot;<TABLE align = &quot;&quot;center&quot;&quot; BORDER=&quot;&quot;1&quot;&quot; CELLSPACING=&quot;&quot;3&quot;&quot; CELLPADDING=&quot;&quot;3&quot;&quot;>&quot; & _
&quot;<TR>&quot; & _
&quot; <TH>Rotation<BR>&quot; & _
&quot; <TH>Abbr<BR>&quot; & _
&quot; <TH>Delete<BR>&quot; & _
&quot; <TH>Edit<BR>&quot; & _


&quot;</TR>&quot;
Do While Not rsRotation.EOF
Response.Write _
&quot;<TR ALIGN=CENTER>&quot; & _
&quot; <TD ALIGN = LEFT>&quot; & rsRotation(&quot;rotation&quot;) & &quot;</a>&quot; & &quot;</TD>&quot; & _
&quot; <TD ALIGN = RIGHT>&quot; & rsRotation(&quot;NewAbbr&quot;) & &quot;</TD>&quot; & _
&quot; <TD ALIGN = LEFT><a href='C_mod_rotation.asp?action=delete&ID=&quot; & rsRotation(&quot;ID&quot;) & &quot;'>DELETE</a>&quot; & &quot;</TD>&quot; & _
&quot; <TD ALIGN = LEFT><a href='C_mod_rotation.asp?action=edit&ID=&quot; & rsRotation(&quot;ID&quot;) & &quot;'>EDIT</a>&quot; & &quot;</TD>&quot; & _
&quot;</TR>&quot;
rsRotation.MoveNext
Loop
response.write &quot; <TR><td colspan=&quot;&quot;4&quot;&quot; Align=right><a href='C_mod_rotation.asp?action=add'>Add new rotation</a></td></TR>&quot;
Response.Write &quot;</TABLE>&quot;
Else ' current user has no Procedures
Response.Write &quot;<CENTER><H2>No Procedures found</H2></CENTER>&quot;
End If
%>
<% if request(&quot;action&quot;) = &quot;add&quot; then%>

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;C_mod_rotation.asp?action=addsave&quot;>
<table width=&quot;52%&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; align=&quot;center&quot;>
<tr>
<td width=&quot;36%&quot;>Rotation</td>
<td width=&quot;64%&quot;>Abbrev</td>
</tr>
<tr>
<td><input type=&quot;text&quot; name=&quot;rotation&quot;></td>
<td><input type=&quot;text&quot; name=&quot;abbr&quot;></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align=&quot;right&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Add this rotation&quot;>
</div></td>
</tr>
</table>
<p>&nbsp;</p>
</form>
<% end if%>
<% if request(&quot;action&quot;) = &quot;edit&quot; then%>

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;C_mod_rotation.asp?action=editsave&ID=<%=rsEditRotation(&quot;ID&quot;)%>&quot;>
<table width=&quot;52%&quot; border=&quot;1&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; align=&quot;center&quot;>
<tr>
<td width=&quot;36%&quot;>Rotation</td>
<td width=&quot;64%&quot;>Abbrev</td>
</tr>
<tr>
<td><input type=&quot;text&quot; name=&quot;rotation&quot; value =&quot;<%=rsEditRotation(&quot;Rotation&quot;)%>&quot;></td>
<td><input type=&quot;text&quot; name=&quot;abbr&quot; value=&quot;<%=rsEditRotation(&quot;newAbbr&quot;)%>&quot;></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><div align=&quot;right&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Update this rotation&quot;>
</div></td>
</tr>
</table>
<p>&nbsp;</p>
</form>
<% end if%>

<!-- #EndEditable --> </td>
</tr>
</table>
<table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;5&quot;>
<tr>
<td align=&quot;center&quot; valign=&quot;middle&quot; class=&quot;footer&quot;> <hr width=&quot;100%&quot; size=&quot;1&quot; noshade>
<p><a href=&quot;file:///C|/Documents%20and%20Settings/csc-student/Local%20Settings/index.cfm&quot;>GME Home</a> | <a href=&quot; target=&quot;_blank&quot;>BCM
Public Site</a> | <a href=&quot; target=&quot;_blank&quot;>BCM
Intranet</a><br>
</p>
<p>&copy; 2002 Baylor College of Medicine</p>
<p>Residency Program<br>
Department of Family and Community Medicine<br>
<b>phone:</b> (713)798-7953 <b>fax:</b> (713)798-7789<br>
Houston, Texas 77030</p>
<p><a href=&quot;mailto:haijunw@bcm.tmc.edu&quot;>haijunw@bcm.tmc.edu</a><br>
modified on Nov, 21 2002</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
 
longmatch,

The code looks good and I can see what you are trying to create.

I can't see anything that is likely to be a problem, though that doesn't mean there isn't one.

I hope it works OK.

If possible, I would love to see the finished page in action.

Cheers,



Barry

ICT Network Administrator
IT Services Manager
 
If you still need examples of a second dropdown dependant on the first, these two FAQ's have examples of the 2 general methods of doing that:
faq333-1498
faq333-3656


-Tarwn

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
minilogo.gif alt=tiernok.com
The never-completed website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top