User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MySQL section within the Web Development category of DaniWeb, a massive community of 391,596 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,706 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MySQL advertiser:
Views: 8054 | Replies: 13
Reply
Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 344
Reputation: Troy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 4
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: select statemt LIKE

  #11  
Aug 1st, 2005
I'm so used to people developing against MySQL using PHP. I ignored the fact that in your earlier post, you posted ASP code. Sorry!

So do this in you HTML:
<select name="car" MULTIPLE>
  <option value="">[All Cars]<option />
  <option value="Acura">Acura<option />
  <option value="Chevy">Chevy<option />
  <option value="Ford">Ford<option />
  <option value="Toyota">Toyota<option />
</select>

Then, in your ASP, if the user submits with multiple options selected, you'll receive them as a comma-seperated list.
<%
cars = Split(Request.Form("car"), ",")
for each car in cars
  Response.Write car & "<br />"
next
%> 
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote  
Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

Re: select statemt LIKE

  #12  
Aug 1st, 2005
oh that's okie! Thanks for replying too!

The code below means getting the values for selecting more than one items?
<%
cars = Split(Request.Form("car"), ",")
for each car in cars
  Response.Write car & "<br />"
next
%> 
i think ive done such statemt, see the code below.
if request.QueryString("statusType") <> "" then
      state = split(request.QueryString("statusType"),"|")
        for each rec in state
          if rsS("statusID") = Cint(rec) then response.Write(" selected")
        next
end if  
i passed in "0" value for the ALL option cos the items in the listbox was passed in in INT datatype so if i passed in empty str for ALL option it gave me an error.

Now when i click both ALL and other items in the listbox it doesnt give me any error but instead it will not go to search for ALL status records. I was thinking if there is any code to maybe validate the users in either selecting the items in the listbox or ALL option and not both. :evil:
Reply With Quote  
Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 344
Reputation: Troy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 4
Troy's Avatar
Troy Troy is offline Offline
Posting Whiz

Re: select statemt LIKE

  #13  
Aug 2nd, 2005
I think you are getting it, but I'm not sure. The points I'm trying to make are:

1. If you want to allow a user to be able to select more than one item in a SELECT list, you must use the MULTIPLE attribute.

2. In ASP, when a SELECT element is submitted that has more than one OPTION selected, it will come in as a comma-seperated list. How you deal with that is your code decision.

Make sense?

I provided a simple code example to show you how to take the comma-seperated list and put it into an array---something easier to work with programmatically than a comma-seperated list of values.

As for validation to ensure the user either selects the "All" option or selects something else, yes you can write client-side javascript to do this validation, but another option is to not do anything. I mean, if the user selects "All" and something else, just treat is as "All"--ignore the other selections since All covers it all. In your ASP code that accepts the form, if you get the zero value (All) in the comma-seperated list, then just write your SQL query to return all values. Otherwise, you'll make your SQL query narrow down the selection accordingly.
Troy Wolf is the author of SnippetEdit. "Website editing as easy as it gets." IX Web Hosting
Reply With Quote  
Join Date: Jul 2005
Posts: 41
Reputation: ohgosh is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ohgosh's Avatar
ohgosh ohgosh is offline Offline
Light Poster

Re: select statemt LIKE

  #14  
Aug 2nd, 2005
Hmm~ i will try to think abt it more seriuosly later.. if there're still problems occuring, i will try to post it again in here..

THANKS!!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb MySQL Marketplace
Thread Tools Display Modes

Other Threads in the MySQL Forum

All times are GMT -4. The time now is 11:34 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC