Link to home
Start Free TrialLog in
Avatar of Wilbat
WilbatFlag for United States of America

asked on

javascript errors

Can anyone please tell me why this code block,
     <script type="text/javascript">
         var i=0
         for (i=0;i<=10;i++)
         {
            document.write("The number is " + i)
           document.write("<br />")
         }
     </script>
specifically the line "for(i=0;i<=10;i++) works with no problem while this code block,
    <SCRIPT language="Javascript">
    <!--
    function addtocombo()
        {
          var i = 0
          var selectedItem
          var selectedText
          var selectedValue
          var newoption1
          var x = 0
          var listLength=document.userslist.menuitems.length
                
          For (x=0; x<listLength; x++)
          {
              if (userslist.menuitems.options(x).selected == 1)
              {
                  selectedItem = document.userslist.menuitems.selectedIndex;
                  selectedText = document.userslist.menuitems.options[x].text;
                  selectedValue = document.userslist.menuitems.options[x].value;
                  newoption1 = new Option(selectedText, selectedValue, false, false);
                  document.userslist.selitems.options[i] = newoption1;
                  i = i + 1
              }
          }
    }

specifically the line "For (x=0; x<listLength; x++)" causes the following error during page load.

Error: missing ) after argument list
Source File: https://www.rosewalker.net/test.asp
Line: 45, Column: 16
Source Code:
    For (x=0; x<listLength; x++)
--------------|
Avatar of Wilbat
Wilbat
Flag of United States of America image

ASKER

nevermind.  It's alsways right in front of you.  I keep forgetting how picky Javascript is.  It doesnt like the keyword For to be capitalized.
Avatar of programmer1024
programmer1024

Since you have solved your own problem, you can ask a moderator to close/cancel this question and refund your points.
ASKER CERTIFIED SOLUTION
Avatar of Computer101
Computer101
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial