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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple selection using asp

Status
Not open for further replies.

jasonhuibers

Programmer
Sep 12, 2005
290
CA
If param5 and param8 are selected then var should be
var = 350,100,351,104,52

How can I do this with asp?


'Book Types
if request("param5") = "1" then
var="350,100,351,104"
elseif request("param6") = "1" then
var="4,121,6,5"
elseif request("param7") = "1" then
var="23,122,35,25,24"
elseif request("param8") = "1" then
var="52"
end if
 
Maybe something like this if you will have other cases of cumulative lists.

[tt]
function AppendList(list, item)
Dim tmpList
tmpList = trim(list)

if trim(item) = "" then
'nothing new to add to list
AppendList = tmpList
Exit Function
end if

'need a comma?
if tmpList <> "")
'be sure last character isn't already a comma
if right(tmpList,1) <> "," then
tmpList = tmpList & ","
end if
end if

'Make function result:
AppendList = tmpList & item
end function




'Book Types (cumulative)
var = ""
if request("param5") = "1" then
var = AppendList(var, "350,100,351,104")
end if
if request("param6") = "1" then
var = AppendList(var, "4,121,6,5")
end if
if request("param7") = "1" then
var = AppendList(var, "23,122,35,25,24")
end if
if request("param8") = "1" then
var = AppendList(var, "52")
end if
[/tt]



If this is the only cumulative list then the above is overkill.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top