Wilbat
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.usersl ist.menuit ems.length
For (x=0; x<listLength; x++)
{
if (userslist.menuitems.optio ns(x).sele cted == 1)
{
selectedItem = document.userslist.menuite ms.selecte dIndex;
selectedText = document.userslist.menuite ms.options [x].text;
selectedValue = document.userslist.menuite ms.options [x].value;
newoption1 = new Option(selectedText, selectedValue, false, false);
document.userslist.selitem s.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++)
--------------|
<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.usersl
For (x=0; x<listLength; x++)
{
if (userslist.menuitems.optio
{
selectedItem = document.userslist.menuite
selectedText = document.userslist.menuite
selectedValue = document.userslist.menuite
newoption1 = new Option(selectedText, selectedValue, false, false);
document.userslist.selitem
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++)
--------------|
Since you have solved your own problem, you can ask a moderator to close/cancel this question and refund your points.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER