•
•
•
•
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
![]() |
•
•
Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 344
Reputation:
Rep Power: 4
Solved Threads: 4
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:
Then, in your ASP, if the user submits with multiple options selected, you'll receive them as a comma-seperated list.
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 %>
oh that's okie! Thanks for replying too!
The code below means getting the values for selecting more than one items?
i think ive done such statemt, see the code below.
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:
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
%> 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 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:
•
•
Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 344
Reputation:
Rep Power: 4
Solved Threads: 4
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.
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.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MySQL Marketplace
Other Threads in the MySQL Forum
- Previous Thread: Preety straightforward!
- Next Thread: Problem w/ LIMIT in CASE statement


Linear Mode