how to show data dynamically by a formula in select menu

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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...
  3. #2

    Default 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...
    > 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
    >
    You could use a split(), seperating on the comma symbol.

    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

  4. #3

    Default 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 much
    Brynn Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139