Ask a Question related to ASP Database, Design and Development.
-
work4u #1
how to show data dynamically by a formula in select menu
I am working on a shopping cart system, which need to show a select menu
dynamically. and all data will be showed follow a formular.
for example:
a record in a field: " 1-10|1,10.5-12|0.5,13-10|-1 "
that is mean from list on select all number from 1 to 10 increase by 1, from
10.5 to 15, increase by 0.5, and from 16 to 20 increase by 1.
so the select menu will list all the result as followed:
1,2,3,4,5,6,7,8,9,10,10.5,11,11.5,12,13,12,11,10
my question is how to use asp to idntify the sign,
like "first number"-"las number"|,"increase step"
please reply with the sample code.
thank you very much
work4u Guest
-
Dynamically Populate Multiple Select Boxes
I am trying to develop an application where a user selects the Year, Make and Model of their vehicle. In the past, I had a query that input the... -
dynamically hide/show delete
Is there a way to selectively hide/show the Delete command button on rows in the datagrid? I realize i can ignore the delete on rows where the is... -
Mathematical formula used in dynamically rendered DataGrid
Hi, I'm trying to find the ASP mathematical formula for the calculation of the width in a dynamically rendered DataGrid with a SQL statement. Is... -
Has Data Formula
What is the name of the subform control? It might not be the same as the name of the form, you are using in the subform control. Also, what... -
Dynamically Show/Hide Groups of TR's
I searched for a while trying to find the answer to this, but to no avail. I am trying to find the best way (or any way) to dynamically show and... -
Dan Boylett #2
Re: how to show data dynamically by a formula in select menu
"work4u" <rossbai@yahoo.com> wrote in message
news:9c872fe0.0401080716.3e45361a@posting.google.c om...from> a record in a field: " 1-10|1,10.5-12|0.5,13-10|-1 "
>
> that is mean from list on select all number from 1 to 10 increase by 1,You could use a split(), seperating on the comma symbol.> 10.5 to 15, increase by 0.5, and from 16 to 20 increase by 1.
>
>
> so the select menu will list all the result as followed:
>
>
> 1,2,3,4,5,6,7,8,9,10,10.5,11,11.5,12,13,12,11,10
>
That would give you an array with :
1-10|1
10.5-12|0.5
You could then run through your array doing string manipulation and If's to
check the result... SOMETHING [1] like this :
For a = 0 to ubound(myArray)
PipePos = Instr(myArray(a),"|")
If PipePos > 0 Then
Increment = Right(myArray(a),PipePos)
DashPos = Instr(myArray(a),"-"
StartNum = Left(myArray(a),DashPos)
EndNum = Mid(myArray(a),DashPos,PipePos)
tmpNum = StartNum
Do While tmpNum <= EndNum
Response.write "<option value = """ & tmpNum & """>" & tmpNum
tmpNum = tmpNum + Increment
Loop
PipePos = 0
End If
Next
[1] This may not work, I dont guarentee it will work. In fact I'm sure it
won't as the string handling will probably be out.
I've written it whilst doing a load of other things.
The idea is a concept on what you could do, not the code. IMO, you should
write your own code.
Dan Boylett Guest
-
Brynn #3
Re: how to show data dynamically by a formula in select menu
Here, I built a function that will return the comma-delimited string
you are looking for. The start number and end number must both be
positive numbers though ... but the increment can be negative. You can
split the comma delimited string of the function into an array and
writ ethe option values ... like the code after my function.
<%
Function cpNumberString(cpTheString)
Dim cpArray1, cpArray2, cpArray3
Dim numOfValues, zinc, cpn, zstart, zend, zcounter, zString
zString = ""
cpArray1 = split(cpTheString, ",")
For cpn = 0 to ubound(cpArray1)
cpArray2 = Split(cpArray1(cpn), "|")
zinc = cpArray2(1) '// INCREMENT
cpArray3 = Split(cpArray2(0), "-")
zstart = FormatNumber(cpArray3(0),1) '// START
NUMBER
zend = FormatNumber(cpArray3(1),1) '// END
NUMBER
numOfValues = ((zend - zstart) / zinc) + 1
For n = 1 to numOfValues
zString = zString & zstart & ","
zstart = 0+ zstart + zinc
Next
Next
zString = Replace(zString & "@", ",@", "") 'zString = zString
'// Get rid of last comma
cpNumberString = Replace(zString, ".0", "")
End Function
Dim yourSelectArray
yourSelectArray =
Split(cpNumberString("1-10|1,10.5-12|0.5,13-10|-1"), ",")
With Response
.Write "<select name=""yourSelectBox"">"
For n = 0 to ubound(yourSelectArray)
.Write "<option value=""" & yourSelectArray(n) & """>"
& yourSelectArray(n) & "</option>"
Next
.Write "</select>"
End With
%>
Please let me know if this helps.
On 8 Jan 2004 07:16:05 -0800, [email]rossbai@yahoo.com[/email] (work4u) wrote:
>I am working on a shopping cart system, which need to show a select menu
>dynamically. and all data will be showed follow a formular.
>
>for example:
>
>
>a record in a field: " 1-10|1,10.5-12|0.5,13-10|-1 "
>
>that is mean from list on select all number from 1 to 10 increase by 1, from
>10.5 to 15, increase by 0.5, and from 16 to 20 increase by 1.
>
>
>so the select menu will list all the result as followed:
>
>
>1,2,3,4,5,6,7,8,9,10,10.5,11,11.5,12,13,12,11,1 0
>
>
>my question is how to use asp to idntify the sign,
>like "first number"-"las number"|,"increase step"
>
>
>please reply with the sample code.
>
>
>thank you very muchBrynn Guest



Reply With Quote

