0

嗨,我在 XML 中有 javascript 代码。如果我在 javascipt 中编写 for loop .the 函数,我的代码就会中断。

{
<script language="javascript">
        IWEventRegistry.addFormHandler("onForminit",init);
        var NextPath="/iwmnt/default/main/sandbox/EDITION/";
        IWEventRegistry.addItemHandler("/Config/NextEditionVpathD","onItemChange",concatPath);
        IWEventRegistry.addItemHandler("/Config/PreviousEditionD","onItemChange",setPrev);
        function init()
        {
            alert("Hello");
            var server = window.location.hostname;
            var param=new Object();
            var callUrl1= "http://"+server+"/iw-cc/teamsite/genEditions.jsp?path1="+NextPath;
            IWDatacapture.callServer(callUrl1,param,true);
            alert("INIT End");

        }

            function genIds1(item)
            {
                var str=item.toString();
                alert(str);
                var n=str.split("-");
                alert("Length is "+n.length);
                item1=IWDatacapture.getItem("/Config/PreviousEditionD");
                alert("Item1 "+ item1);
                for(var i=0;i<n.length-1;i++)
                {
                    alert(n[i]);
                }



            }
         function concatPath()
       {
           var item = IWDatacapture.getItem("/Config/NextEditionVpathD").getValue();
           var path=NextPath+item;
           IWDatacapture.getItem("/Config/NextEditionVpath").setValue(path);
           alert("Next Edition "+IWDatacapture.getItem("/Config/NextEditionVpath").getValue());   
       }
       function setPrev()
       {
            var item = IWDatacapture.getItem("/Config/PreviousEditionD");
            var item1=item.getOptions()[item.getValue()].value;
            IWDatacapture.getItem("/Config/PreviousEdition").setValue(item1);
            alert("previous Edition  " +item1);
       }
        </script>
}

如果我不使用 for 循环,但在 for 循环之后,此代码工作正常,在执行时它给出标题中提到的错误。你能告诉我如何解决它。

{org.apache.xmlbeans.XmlException:错误:遇到意外字符(lex state 8):';'} 谢谢

4

0 回答 0