Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 5th, 2005, 03:28 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Hi,

You make a very good case for using an identity column. However, this code works like a charm. It seems that it does work using ASP to encode the URL but for some reason once you encode the text it doesn't add the comma delimiter on the post so I just added it to the javascript: strSel += sel[item].value + ",\n";

Never have I seen so many posts to such a simple problem. Tulin, you are a lucky man.

CREATE TABLE [Supplier] (
    [SuppID] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL ,
    [SuppName] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
    [Supptext] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO

<html>
<head>
<title>Select Test</title>
<script language="javascript">
   function getSelected(opt) {
      var selected = new Array();
      var index = 0;
      for (var intLoop=0; intLoop < opt.length; intLoop++) {
         if (opt[intLoop].selected) {
            index = selected.length;
            selected[index] = new Object;
            selected[index].value = opt[intLoop].value;
            selected[index].index = intLoop;
         }
      }
      return selected;
   }
         function outputSelected(opt) {
            var sel = getSelected(opt);
            var strSel = "";
            for (var item in sel)
            //alert (sel[item].value)
               strSel += sel[item].value + ",\n";
              // alert("Selected Items:\n" + strSel);
            window.location='select.asp?Supplier=' + strSel;

         }
</script>
</head>
<body leftmargin="0" topmargin="0">
<br><br>
<form Name="myform" method="post">
<select NAME="Supplier" SIZE=4 MULTIPLE >
<option value="<% Response.Write Server.URLencode("Red & Lease") %>">Red & Lease</option>
<option value="<% Response.Write Server.URLencode("Tech & Lease") %>">Tech & Lease</option>
<option value="<% Response.Write Server.URLencode("richie&Lease") %>">richie&Lease</option>
<option value="<% Response.Write Server.URLencode("bill&Lease") %>">bill&Lease</option>
</select>
<br>
<INPUT TYPE="BUTTON" NAME="open" VALUE="SUBMIT" ONCLICK="outputSelected(this.form.Supplier.options )">
<br>
<%
    supplier = Trim(Request("Supplier"))
    If Len(supplier) > 0 Then
    thevalues = split(supplier, ",")
    Set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Open Application("conn")
    For i = 0 to ubound(thevalues)
    SQL = "Select * from Supplier where SuppName = '" & thevalues(i) & "';"
        Set oRS = oConn.Execute(SQL)
        If not oRS.EOF Then
        Response.Write "<br><b>Supplier:</b> " & oRS("SuppName") & " - - - - " & oRS("Supptext") & "<br>"
        End If
    Next
    oRS.Close
    Set oRS = Nothing
    oConn.Close
    Set oConn = Nothing
    End If
%>
</body>
</html>

 
Old October 5th, 2005, 03:33 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Hi Tulin,

I knew this would work but had to write a complete page to figure it out. There's a couple of things. I noticed that if you don't use the double quotes on select values they get cut off if there are spaces in the values. Also, Server.URLencode does work fine except that I had to had a comma to a line in the javascript: strSel += sel[item].value + ",\n"; because with the URL encoding the comma is not added and makes it impossible to SPLIT the string.

I have tried posting the code to the page that works but the post keeps getting rejected, maybe cause its too long.

Thanks


 
Old October 6th, 2005, 01:16 PM
Authorized User
 
Join Date: Aug 2005
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I really appreciate for all your help. I used Server.URLencode and I solved my problem.

It was really painfull but I learned a lof from you.

Thanks, again...






Similar Threads
Thread Thread Starter Forum Replies Last Post
Grab Values From List Box into Text Box phungleon VB How-To 2 June 19th, 2008 10:33 PM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
passing values from multiple list box tulincim Javascript 4 September 14th, 2005 02:02 AM
passing values from multiple list box tulincim Classic ASP Basics 4 September 13th, 2005 06:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.