javascript错误(动态表生成) [英] javascript error (dynamic table generation)

查看:62
本文介绍了javascript错误(动态表生成)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI,


我正在使用javascript和dom创建一个页面。当我从下拉菜单中选择一个选项后进入新窗口并按下基准时,表格显示在同一个新页面中。


这是我的一段代码我不能传递并打印生成完整表所需的所选选项的值。


====================== ==

展开 | 选择 | Wrap | 行号

解决方案

首先,欢迎来到TSDN!

Re。你的问题:你如何调用函数以及错误消息是什么?在哪一行?



首先,欢迎到TSDN!


Re。你的问题:你如何调用该函数以及错误消息是什么以及在哪一行?



感谢welcome.I检查浏览器类型如果然后在evey中或者我调用函数yI得到对象预期错误,第1行char1


这是完整的代码: -


======================= ======

code(javascipt)


[HTML]< html>

< head>

< script language =" javascript">

var xmlDoc;


function showerror(error)

{

ewin = open("","","");

ewin.document.open ();

ewin.document.write(< b> XML解析错误< / b>< br>< br>错误#:" + error.errorCode +" < br>说明:" + error.reason +"< br>在档案中:" + error.url +"< br>行:




ewin.document.close();

}


函数y()

{

nwin = open("","","");

nwin.document.open();

var it = xmlDoc.documentElement .childNodes [0] .getElementsByTagName(" item");

var le = it.length;

nwin.document.write("< div id = ''inside''> sab< / div>");

函数fun()

{

nwin.document.write (< form id =''f1''>< select id =''s1''>");

for(var i = 0;我< le; i ++)

{

n = it.item(i);

nwin.document.write("< option value = \ "" + i +" \">" + n.childNodes [0] .text +"< / option>");


}

nwin.document.write("< / select>");

var r = document.f1.s1.selectedIndex;

var ChosenTitle = document.f1.s1.options [r] .text;

var outtext + ="< b>" + ChosenTitle +"< / b>"

document.getElementById(" inside")。innerHTML = outtex t;

}


nwin.document.write( "< input type =''button''value =''get details''onClick =''fun();''>< / form>");

nwin .document.close();

}

函数x(文件)

{


//我的代码E

if(window.ActiveXObject)

{

xmlDoc = new ActiveXObject(" Microsoft.XMLDOM");

xmlDoc.async = false;

xmlDoc.load(file);

if(xmlDoc.parseError.errorCode!= 0)

{

showerror(xmlDoc.parseError);

}

else

{

y();

}


}


// Mozilla,Firefox,Opera等代码。

else if(document.implementation&& document.implementation.createDocument)

{

xmlDoc = document.implementation.createDocument("","",null);

//xmlDoc.load(file);

xmlDoc.async = false;

if(!xmlDoc.load(file))

{

alert(''XML文件中的错误');

}

else

{< br $>
y();

}

}


其他

{

alert(''浏览器无法处理此脚本'');

}

xmlDoc.async = false;

}


< / script>

< / head>


< ; body>

< form name =" form1">

< b>输入XML文件< / b>< br&g t;

< input type =" text"值= QUOT;" ID = QUOT; T1"大小= QUOT; 100" maxlength =" 100">< br>

< input type =" button"值= QUOT按钮"名称= QUOT; button1的" onClick =" x(t1.value);">

< / form>

< / body>

< ; / HTML> [/ HTML]

HI,

I am creating a page using javascript and dom. when i go to the new window and press abutton after selecting a option from a dropdown menu the table shoub appear within the same new page .

Here is my piece of code I am not able to pass and print the value of selected option needed to generate a complete table.

========================

Expand|Select|Wrap|Line Numbers

解决方案

First of all, welcome to TSDN!

Re. your problem: how do you call the function and what''s the error message and on which line?


First of all, welcome to TSDN!

Re. your problem: how do you call the function and what''s the error message and on which line?

Thanks for welcome.I check the browser type throuht if then and in evey if or then i call function y.I get object expected error, line 1 char1

Here is the complete code:-

=============================
code(javascipt)

[HTML]<html>
<head>
<script language="javascript">
var xmlDoc;


function showerror(error)
{
ewin=open("","","");
ewin.document.open();
ewin.document.write("<b>XML parsing error</b><br><br>Error#: "+error.errorCode+"<br>Description: "+error.reason+"<br>In file: "+error.url+"<br>Line:



ewin.document.close();
}

function y()
{
nwin=open("","","");
nwin.document.open();
var it=xmlDoc.documentElement.childNodes[0].getElementsByTagName("item");
var le=it.length;
nwin.document.write("<div id=''inside''>sab</div>");
function fun()
{
nwin.document.write("<form id=''f1''><select id=''s1''>");
for(var i = 0; i <le; i++)
{
n = it.item(i);
nwin.document.write("<option value=\""+i+"\">"+n.childNodes[0].text+"</option>");

}
nwin.document.write("</select>");
var r=document.f1.s1.selectedIndex;
var ChosenTitle = document.f1.s1.options[r].text;
var outtext+="<b>"+ChosenTitle+"</b>"
document.getElementById("inside").innerHTML=outtex t;
}

nwin.document.write("<input type=''button'' value=''get details'' onClick=''fun();''></form>");
nwin.document.close();
}
function x(file)
{

// code for IE
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async=false;
xmlDoc.load(file);
if (xmlDoc.parseError.errorCode != 0)
{
showerror(xmlDoc.parseError);
}
else
{
y();
}

}

// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
xmlDoc=document.implementation.createDocument(""," ",null);
//xmlDoc.load(file);
xmlDoc.async=false;
if(!xmlDoc.load(file))
{
alert(''Error in XML file'');
}
else
{
y();
}
}

else
{
alert(''browser cannot handle this script'');
}
xmlDoc.async=false;
}


</script>
</head>

<body>
<form name="form1">
<b>Enter XML File </b><br>
<input type="text" value="" id="t1" size="100" maxlength="100"><br>
<input type="button" value="button" name="button1" onClick="x(t1.value);">
</form>
</body>
</html>[/HTML]


这篇关于javascript错误(动态表生成)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆