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!

combo select boxes in HTML working with ASP

Status
Not open for further replies.

taval

Programmer
Jul 19, 2000
192
GB
Currently I have a I have an asp page front end that is linked to a database query asp. The front-end consists of a text boxes and associated buttons.<br>i.e.<br>----------------<br><br>Search by Customer ID &lt;text box&gt; &lt;button&gt;<br>Search by Customer Name &lt;text box&gt; &lt;button&gt;<br>Search by Customer E-Mail &lt;text box&gt; &lt;button&gt; <br><br>----------------<br><br>when any of the buttons associated with a query search on something such as &quot;Customer ID&quot; is pressed another asp script is called that processes the query with the variable inside the text box. I have already got this working.<br><br>My problem is that doing it this way takes up more space and means the page has less integrity. I would like to make it so that &quot;Customer ID&quot;,&quot;Customer Name&quot; etc come up in a combo box with one button next to it. When the button is pressed the database query script loads up. How do I implement the html code for the combo box? How can I code the asp script so it knows what option was selected from the combo box so it knows what query to process.<br><br>my database query script looks something like this:<br><br>-------------------------------------------------<br><br>&lt;html&gt;<br>&lt;head&gt;<br>&lt;title&gt;Database Test&lt;/title&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;% <br>Dim rs<br>Dim StrQuery<br>Dim strAction<br>Dim strSQL<br>Dim rsFileDesc<br><br>strAction = Request.Form(&quot;button&quot;)<br><br>Select Case strAction<br><br>Case &quot;Search ID&quot;<br><br>StrQuery = &quot;Select * from Customer where CustID = &quot; & Cint(Request(&quot;CustID&quot;))& &quot;&quot;<br><br>Case &quot;Search Name&quot;<br><br>StrQuery = &quot;Select * from Customer where CustName = &quot; & &quot;'&quot; & Request(&quot;CustName&quot;)& &quot;'&quot;<br><br>Case &quot;Search Query&quot;<br><br>StrQuery = &quot;Select * from Customer&quot;<br><br>Case &quot;List All Customers&quot;<br><br>StrQuery = &quot;Select * from Customer&quot;<br>Set rs = Server.CreateObject (&quot;ADODB.Recordset&quot;)<br>rs.Open StrQuery ,&quot;DSN=Architron; UID=sa; PWD=&quot;<br><br><br>rs.MoveFirst<br>%&gt;<br><br>&lt;table cellpadding=&quot;1&quot; cellspacing=&quot;1&quot; BORDER=&quot;0&quot; WIDTH=&quot;850&quot; &gt;<br>&lt;tr&gt;<br>&lt;td align= &quot;center&quot; width=&quot;70&quot; bgcolor=#CCCCCC &gt;Customer ID&lt;/td&gt;<br><br>&lt;td align= &quot;center&quot; width=&quot;150&quot; bgcolor=#CCCCCC &gt;Customer Name&lt;/td&gt;<br><br>&lt;td align= &quot;center&quot; width=&quot;120&quot; bgcolor=#CCCCCC &gt;Phone&lt;/td&gt;<br><br>&lt;td align= &quot;center&quot; width=&quot;120&quot; bgcolor=#CCCCCC &gt;Fax&lt;/td&gt;<br><br>&lt;td align= &quot;center&quot; width=&quot;150&quot; bgcolor=#CCCCCC &gt;E-mail&lt;/td&gt;<br><br>&lt;td align= &quot;center&quot; width=&quot;110&quot; bgcolor=#CCCCCC &gt;Space Allocated (MB)&lt;/td&gt;<br><br>&lt;td align= &quot;center&quot; width=&quot;60&quot; bgcolor=#CCCCCC &gt;Space Used&lt;/td&gt;<br>&lt;/tr&gt;<br>&lt;%<br>While Not rs.EOF %&gt;<br>&lt;TR&gt;&lt;TD align= &quot;center&quot; BGCOLOR=&quot;#99FF99&quot;&gt;&nbsp;&nbsp;&nbsp;&nbsp;&lt;% Response.Write rs(&quot;CustID&quot;) %&gt;&lt;/TD&gt; <br>&lt;TD BGCOLOR=&quot;#99FF99&quot;&gt;&nbsp;&nbsp;&lt;% Response.Write rs(&quot;CustName&quot;)&nbsp;&nbsp;%&gt;&lt;/TD&gt; <br>&lt;TD BGCOLOR=&quot;#99FF99&quot;&gt;&nbsp;&nbsp;&lt;% Response.Write rs(&quot;Phone&quot;) %&gt;&lt;/TD&gt;<br>&lt;TD BGCOLOR=&quot;#99FF99&quot;&gt;&nbsp;&nbsp;&lt;% Response.Write rs(&quot;Fax&quot;) %&gt;&lt;/TD&gt;<br>&lt;TD BGCOLOR=&quot;#99FF99&quot;&gt;&nbsp;&nbsp;&lt;% Response.Write rs(&quot;email&quot;) %&gt;&lt;/TD&gt; <br>&lt;TD align= &quot;center&quot; BGCOLOR=&quot;#99FF99&quot;&gt;&nbsp;&nbsp;&lt;% Response.Write rs(&quot;SpaceAllocationInMB&quot;) %&gt;&lt;/TD&gt;<br>&lt;TD align= &quot;center&quot; BGCOLOR=&quot;#99FF99&quot;&gt;&nbsp;&nbsp;&lt;% Response.Write rs(&quot;SpaceUsed&quot;)%&gt;&lt;/TD&gt;&lt;/TR&gt; <br>&lt;%<br>rs.MoveNext<br>Wend %&gt;<br><br>&lt;/Table&gt;<br>&lt;% <br><br>Response.End <br><br>End select<br><br>Set rs = Server.CreateObject (&quot;ADODB.Recordset&quot;)<br>rs.Open StrQuery ,&quot;DSN=Architron; UID=sa; PWD=&quot;<br><br>if Not rs.EOF then<br>rs.movefirst<br>While Not rs.EOF<br>Response.Write &quot;Customer ID: &quot; & rs(&quot;CustID&quot;)& &quot;&lt;br&gt;&quot;<br>Response.Write &quot;Customer Name : &quot; & rs(&quot;CustName&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;Address: &quot; & rs(&quot;Address1&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;: &quot; & rs(&quot;Address2&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;: &quot; & rs(&quot;Address3&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;: &quot; & rs(&quot;Address4&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;: &quot; & rs(&quot;Address5&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;PostCode: &quot; & rs(&quot;PostCode&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;Phone: &quot; & rs(&quot;Phone&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;Fax: &quot; & rs(&quot;Fax&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;E-mail: &quot; & rs(&quot;email&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;Can Upload: &quot; & rs(&quot;CanUpload&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;Can Download: &quot; & rs(&quot;CanDownLoad&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;Space Allocated (MB) : &quot; & rs(&quot;SpaceAllocationInMB&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;Space Used: &quot; & rs(&quot;SpaceUsed&quot;) & &quot;&lt;br&gt;&quot;<br>Response.Write &quot;&lt;br&gt;&quot;<br>rs.MoveNext<br>Wend<br><br>strSQL = &quot;Select * from FileDescription where CustId = &quot; & Cint(Request(&quot;CustID&quot;))& &quot;&quot;<br><br>Set rsFileDesc = Server.CreateObject (&quot;ADODB.Recordset&quot;)<br>rsFileDesc.Open strSQL ,&quot;DSN=Architron; UID=sa; PWD=&quot;<br><br>if rsFileDesc.EOF then<br>else<br>rsFileDesc.MoveFirst<br>While not rsFileDesc.EOF<br>&nbsp;&nbsp;Response.write &quot;File ID: &quot; & rsFileDesc(&quot;FileID&quot;)& &quot;&lt;br&gt;&quot;<br>&nbsp;&nbsp;Response.write &quot;File Name: &quot; & rsFileDesc(&quot;FileName&quot;)& &quot;&lt;br&gt;&quot;<br>&nbsp;&nbsp;Response.write &quot;File Size: &quot; & rsFileDesc(&quot;Size&quot;)& &quot;&lt;br&gt;&quot;<br>&nbsp;&nbsp;Response.write &quot;Last Modified: &quot; & rsFileDesc(&quot;LastModified&quot;)& &quot;&lt;br&gt;&quot;<br>&nbsp;&nbsp;Response.write &quot;Attributes: &quot; & rsFileDesc(&quot;Attributes&quot;)& &quot;&lt;br&gt;&quot;<br>&nbsp;&nbsp;Response.write &quot;Compressed: &quot; & rsFileDesc(&quot;Compressed&quot;)& &quot;&lt;br&gt;&quot;&nbsp;&nbsp;<br>&nbsp;&nbsp;Response.write &quot;Customer ID: &quot; & rsFileDesc(&quot;CustId&quot;)& &quot;&lt;br&gt;&quot;<br>&nbsp;&nbsp;Response.write &quot;Upload Date: &quot; & rsFileDesc(&quot;UploadDate&quot;)& &quot;&lt;br&gt;&quot;<br>&nbsp;&nbsp;Response.write &quot;Image ID: &quot; & rsFileDesc(&quot;ImageId&quot;)& &quot;&lt;br&gt;&quot;<br>&nbsp;&nbsp;Response.write &quot;Stored Size: &quot; & rsFileDesc(&quot;StoredSize&quot;)& &quot;&lt;br&gt;&quot;<br>&nbsp;&nbsp;Response.write &quot;&lt;br&gt;&quot;<br>&nbsp;&nbsp;rsFileDesc.MoveNext <br>wend<br>end if<br>else<br>&nbsp;&nbsp;Response.write &quot; No Match Record Found&quot; & &quot;&lt;br&gt;&quot;<br>end if<br><br>rs.Close<br>rsFileDesc.close<br>Set rs = Nothing <br>Set rsFileDesc = Nothing %&gt;<br>&lt;/body&gt;<br>&lt;/html&gt; <br><br>-------------------------------------------------<br><br>Note: I have a select case block which determines the button pressed and selects the correct query, right now.<br><br>Grateful for any help given, :].<br>
 
If I'm not mistaken, you pass the button's caption value as a parameter to your select statements. <br>You could use just one textbox,certain amount of &quot;radio&quot; buttons(depending on number of parameters you want to search by)and one submit button:<br><br>&lt;form name=&quot;search&quot; action=&quot;search.asp&quot; method=&quot;post&quot;&gt;<br>&nbsp;&lt;input type=&quot;text&quot; name=&quot;param&quot;&gt;<br>&nbsp;&lt;input type=&quot;radio&quot; name=&quot;by&quot; value=&quot;custID&quot; checked&gt;By customer ID<br>&nbsp;&lt;input type=&quot;radio&quot; name=&quot;by&quot; value=&quot;custName&quot;&gt;By customer name<br>&nbsp;&lt;input type=&quot;radio&quot; name=&quot;by&quot; value=&quot;custName&quot;&gt;By customer e-mail<br>&nbsp;&lt;input type=&quot;radio&quot; name=&quot;by&quot; value=&quot;all&quot;&gt;All <br>&lt;input type=&quot;submit&quot; value=&quot;Find It&quot;&gt;<br>&lt;/form&gt; <br>---------------------------------<br>then in your search script will be:<br><br>select case request.form(&quot;by&quot;)<br>case &quot;all&quot;<br>strSQL = &quot;Select * from Customers&quot;<br>case else<br>strSQL = &quot;Select * from Customers where &quot; & request.form(&quot;by&quot;)& &quot; = &quot; & request.form(&quot;param&quot;)<br>end select<br>
 
I'm sorry, I forgot that you have a numeric field in your database.So, you might want to add another case to the script where you convert to integer or any other numeric datatype the value of &quot;param&quot; textbox.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top