Count total value from scrolldown menus.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ZyPhiX

    #1

    Count total value from scrolldown menus.

    Hi, I've got a little problem:

    I'm trying to make a webpage with a few scrolldown menu's and I want
    to count the values of them. In the scrolldown menu's are no numeric
    values but the have to represent one. I hope I can explain it a little
    bit better:

    Scrolldownmenu 1:
    - Option A (name A) --> (this has to represent te value 10 for
    example)
    - Option B (name B) --> (this has to represent te value 32 for
    example)

    Scrolldownmenu 2:
    - Option A (name A) --> (this has to represent te value 15 for
    example)
    - Option B (name B) --> (this has to represent te value 30 for
    example)

    etc.. (a few other ones)



    So I wanna count the values they represent to a total and put it in a
    textfield. And if you select a name that i will add that value to the
    total or update it (whitout refreshing the page).

    And is it then also possible to give an error message if the total
    value is above a specified value?

    I think it is possible with javascript but I'm not that experienced.

    Hopefully I explained it good enough and someone can help me.


    thanks.
  • DJ WIce

    #2
    Re: Count total value from scrolldown menus.

    Maybe you just want to use a free script that is easy to implement and
    tested:



    Wouter

    "ZyPhiX" <mk@zyphix.co m> wrote in message
    news:2778f05b.0 402020707.52507 b3b@posting.goo gle.com...
    : Hi, I've got a little problem:
    :
    : I'm trying to make a webpage with a few scrolldown menu's and I want
    : to count the values of them. In the scrolldown menu's are no numeric
    : values but the have to represent one. I hope I can explain it a little
    : bit better:
    :
    : Scrolldownmenu 1:
    : - Option A (name A) --> (this has to represent te value 10 for
    : example)
    : - Option B (name B) --> (this has to represent te value 32 for
    : example)
    :
    : Scrolldownmenu 2:
    : - Option A (name A) --> (this has to represent te value 15 for
    : example)
    : - Option B (name B) --> (this has to represent te value 30 for
    : example)
    :
    : etc.. (a few other ones)
    :
    :
    :
    : So I wanna count the values they represent to a total and put it in a
    : textfield. And if you select a name that i will add that value to the
    : total or update it (whitout refreshing the page).
    :
    : And is it then also possible to give an error message if the total
    : value is above a specified value?
    :
    : I think it is possible with javascript but I'm not that experienced.
    :
    : Hopefully I explained it good enough and someone can help me.
    :
    :
    : thanks.


    Comment

    • ZyPhiX ZyPhiX

      #3
      Re: Count total value from scrolldown menus.

      That's not exactly what I'm looking for. I mean something like on this
      page:

      Maybe "listbox" is a better word?


      Verstappen.com is the official website of Max Verstappen. It brings the latest news, photos and results.



      And then I want to add a value to each option. So I can make a total
      sum of the selected values.

      Hope it's clear now?


      *** Sent via Developersdex http://www.developersdex.com ***
      Don't just participate in USENET...get rewarded for it!

      Comment

      • @SM

        #4
        Re: Count total value from scrolldown menus.

        ZyPhiX a ecrit :[color=blue]
        >
        > I'm trying to make a webpage with a few scrolldown menu's and I want
        > to count the values of them. In the scrolldown menu's are no numeric
        > values but the have to represent one. I hope I can explain it a little
        > bit better:[/color]

        to add the value of row (1st row, 2nd, 3rd etc) in field "MyTotal"
        and
        to add the values of options in field "BigTotal"

        <html>
        <script type="text/javascript"><!--
        function getRowNumber(My Menu,Field1,Fie ld2) {
        if(document.all ) {
        r = document.Field1 ;
        c = document.Field2 ;
        t = document.all['MyTotal'];
        tt = document.all['BigTotal'];
        }
        else
        if(document.get ElementsByName) {
        r = document.getEle mentsByName(Fie ld1)[0];
        c = document.getEle mentsByName(Fie ld2)[0];
        t = document.getEle mentsByName('My Total')[0];
        tt = document.getEle mentsByName('Bi gTotal')[0];
        }
        else {
        r = document.forms['MyForm'].elements[Field1];
        c = document.forms['MyForm'].elements[Field2];
        t = document.forms['MyForm'].elements['MyTotal'];
        tt = document.forms['MyForm'].elements['BigTotal'];
        }
        r.value = MyMenu.options. selectedIndex+1 *1;
        t.value = t.value*1+r.val ue*1;
        c.value = MyMenu.options[MyMenu.options. selectedIndex].value;
        tt.value = tt.value*1+c.va lue*1;
        if(tt.value>150 ) alert('That\'s too much !');
        }

        // --></script>

        <form name="MyForm">
        <p><select name="Scrolldow nmenu_1"
        onchange="if(th is.options.sele ctedIndex>0)
        getRowNumber(th is,'showR_1','s howV_1');">
        <option>Choic e 1
        <option value="5">A
        <option value="3">B
        </select>
        <br>choosen Row 1 :<input type=text name="showR_1">
        <br>choosen Value 1 :<input type=text name="showV_1">
        <p><select name="Scrolldow nmenu_2"
        onchange="if(th is.options.sele ctedIndex>0)
        getRowNumber(th is,'showR_2','s howV_2');">
        <option>Choic e 2
        <option value="15">A
        <option value="31">B
        </select>
        <br>choosen Row 2 :<input type=text name="showR_2">
        <br>choosen Value 2 :<input type=text name="showV_2">
        <p>Total rows : <input type=text name="MyTotal">
        Total values : <input type=text name="BigTotal" >
        </form>
        </html>

        --
        ******** (enlever/remove [OTER_MOI] du/from reply url) *******
        Stéphane MORIAUX : mailto:stephane OTER_MOImoriaux @wanadoo.fr
        Aide aux Pages Perso (images & couleurs, formulaire, CHP, JS)

        *************** *************** *************** *************** **

        Comment

        • ZyPhiX

          #5
          Re: Count total value from scrolldown menus.

          Oke thanks a lot. I'm going to try it.


          thx.


          "@SM" <stephanemorOTE Z_MOIiaux@wanad oo.fr> wrote in message news:<401E89DD. 218CD061@wanado o.fr>...[color=blue]
          >
          > Answer[/color]

          Comment

          Working...