Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 12th, 2005, 05:41 PM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default passing values from multiple list box

Hello everyone,

I am really having hard time to retrieve data from database using multiple list box. Here is the my simplified version of codes that you may want to take look...

<select NAME="Supplier" SIZE=4 MULTIPLE >
<%While NOT rsMain.EOF%>
<option value=<%=rsMain("Supplier Name")%>><%=rsMain("Supplier Name")%></option>
<%rsMain.MoveNext()
Wend%>
</select>


<INPUT TYPE="BUTTON" NAME="open" VALUE="SUBMIT" ONCLICK="outputSelected(this.form.Supplier.options )">

<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='SupplierFilterTest.asp?Supp=' + strSel;

         }
      </SCRIPT>

<%SSupp= Request("Supp")%>

strOpenPO= "SELECT Count(PONUMBER) AS OpenPos FROM MyTable WHERE SUPPLIER ='" &SSupp& "'"

When I take a look inside SSupp, all variables are appending each other without any space.

When I select only one value from list box, my code is working fine. But whenever I select more than one, I get nothing.

Any help would be appreciated,

Thanks,

-Tulin


Reply With Quote
  #2 (permalink)  
Old September 13th, 2005, 09:20 AM
Authorized User
 
Join Date: Jul 2005
Location: New York, New York, .
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did you try the keyword IN?
ie.

"SELECT Count(PONUMBER) AS OpenPos FROM MyTable WHERE SUPPLIER
in (" &SSupp& ")"


Reply With Quote
  #3 (permalink)  
Old September 13th, 2005, 11:34 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It doesn't work. I tried everything "LIKE ,IN" ...

My main problem is that I can't diffrentiate suppliers. They are appending each other without any space. For example, I get Supplier1, Supplier2, Supplier3 from Javascript code. But when pass the values to asp with <%SSupp= Request("Supp")%> code,
I get SSupp= Supplier1Supplier2Supplier3. I used replace function, but i can't successful.

Any suggestion would be appreciated.

Thanks...





Reply With Quote
  #4 (permalink)  
Old September 13th, 2005, 11:35 AM
Authorized User
 
Join Date: Aug 2005
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It doesn't work. I tried everything "LIKE ,IN" ...

My main problem is that I can't diffrentiate suppliers. They are appending each other without any space. For example, I get Supplier1, Supplier2, Supplier3 from Javascript code. But when pass the values to asp with <%SSupp= Request("Supp")%> code,
I get SSupp= Supplier1Supplier2Supplier3. I used replace function, but i can't successful.

Any suggestion would be appreciated.

Thanks...


Reply With Quote
  #5 (permalink)  
Old September 13th, 2005, 06:40 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

;;;It doesn't work. I tried everything "LIKE ,IN" ...
print your query to the browser and post it


You should have a commer delimited string of integers in the SSupp value to use IN.

rsMain("Supplier Name") doesnt sound like an integer to me.

BTW : why would you want to retrieve these values on the client side

IMO you should place the unique ID (auto incrimenting integer)which should be your primary key in the value of each of your items in the multiple select list. When they get posted the value will lokk like:
1,5,7,9
Then do your SELECT WHERE IN statement.

If you dont have a unique identifyer for each of your records to do such a thing, create one. Even if you dont need it, put it there. There is a good chance you may need it in the future for updating, deleting, inactivating, archiving records etc.

Wind is your friend
Matt
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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 Classic ASP Databases 22 October 6th, 2005 01:16 PM
passing values from multiple list box tulincim Javascript 4 September 14th, 2005 02:02 AM



All times are GMT -4. The time now is 03:04 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.