Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    349
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Unique way to tally qty boxes using Dom?? how

    Is there an effective way to grab all the qty dropdown input values and add them without reiterating thru all the element form objects on the page and then IF they have qty in their name, add the values....seems kinda overkill or outdated.....

    Is there way to just grab the selected values of the select boxes that have 'qty' as part of the name??? Of course I can apply a unique ID, or NAME or Whatever to the qty dropdowns.....

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmmm;

    I do not think there is a magical way of determing if a form elements name contains qty without iterating thru the form elements......

    Unless of course you want to start with all tagNames.
    But now that would be overkill......

  • #3
    Regular Coder Vincent Puglia's Avatar
    Join Date
    Jul 2003
    Location
    where the World once stood
    Posts
    367
    Thanks
    0
    Thanked 13 Times in 13 Posts
    Hi,

    Since your asking I've got to presume you have umpteen thousand selection lists -- else the looping through the form's elements & list's options would not be that tedious -- especially since it's the machine and not you doing it

    <select ..... onchange='doit(this.name, this.selectedIndex)'

    var selNdces = new Array();
    function doit(selName, ndx)
    {
    selNdces[selName] = ndx;
    }

    you can then access them with:

    for (theName in selNdces)
    alert(theName + ' = ' + selNdces[theName])

    or if you want the list's value:

    for (theSel in selNdces)
    {
    oSel = document.formname[theSel] // replace with the form's name
    alert(oSel.options[selNdces[theSel]].value)
    }


    Vinny
    Where the world once stood
    the blades of grass
    cut me still


  •  

    Posting Permissions

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