Finding the value of a pull-down menu

    Date: 02/27/06 (Javascript Community)    Keywords: no keywords

    I've been working on my huge form some more and I think I've narrowed down at least one of the problems to the following code:

    function updateReg() {
        var title = "";
        var dateIndex = calculateDate();
        RegFees = 0;
        for(i=1;i<=4;i++)
         {
          var which = "document.form1.cat"+i;
          var sel = eval(which+".selectedIndex");
          alert("i = " + i + ", sel = " + sel);
          var t = eval(which+".options["+sel+"].value");
          alert("i = " + i + ", t = " + t);
          if(t != "--Choose One--")
           {
            title += "R"+i+" - "+t+" - $"+Categories[sel][dateIndex]+".00\n";
            RegFees += Categories[sel][dateIndex];
           }
         }
        document.form1.reg_title.value = title;
        updateTotal();
    }


    Especially this line:
    var t = eval(which+".options["+eval(which+".selectedIndex")+"].value");


    It works fine in Firefox but in IE I keep getting t="" instead of the value of the cat1 (cat2, etc) menu.

    Source: http://community.livejournal.com/javascript/94913.html

« To scroll or not to scroll... || Raw Noobage »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home