JS如何调用其他格式文件中的数据生成HTML页面?

along203 2003-10-30 11:47:14
下面是Questions.ptf文件内容:
<Questions><Question><Title>题目一</Title><Content>1+1=?
</Content><Options>1
2
3
4
</Options><Key>1
</Key></Question>
----------------------------
在一个HTML中如何调用其数据生成一道选择题,<Key>1</Key>表示正确答案为第二个复选框.页面显示如下:
-------------------------
题目一
1+1=?
(复选框) 1
(复选框) 2
(复选框) 3
(复选框) 4
-------------------------
谢谢!
...全文
92 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
fastson 2003-10-30
  • 打赏
  • 举报
回复
使用xml
along203 2003-10-30
  • 打赏
  • 举报
回复
能给个例子么,有于时间太紧,没时间全都学.
看起来很麻烦!
becool 2003-10-30
  • 打赏
  • 举报
回复
XML+javascript+样式表
along203 2003-10-30
  • 打赏
  • 举报
回复
多谢JK!可能我还没表达清楚我的意思。目的是需要从一个包含所有题目的文件(如Questions.ptf)中调出一个题目显示在HTML页面,点击下一题再调出下一个题目,而前一题则在不显示。就象调用数据库一样。那该怎么办?
JK_10000 2003-10-30
  • 打赏
  • 举报
回复
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>支持民族工业,尽量少买日货</title>
</head>
<IE:Download ID="oDownload" STYLE="behavior:url(#default#download)" />
<body>
<BR>
<input type=button value="得到题目" onclick="oDownload.startDownload('QuestionData1.htm',changeQuestion);">
<div id=aaa></div>

</body>

</html>
<script>

function changeQuestion(QuestionStr)
{
aaa.innerHTML=QuestionStr;
}
</script>
along203 2003-10-30
  • 打赏
  • 举报
回复
但如果需要先显示第一题,点击下一题再显示第二题.而且不能直接载入一个htm页面,就如我上面所说的,那该怎么办?用XML应如何写?谢谢!
JK_10000 2003-10-30
  • 打赏
  • 举报
回复
QuestionData1.htm:
-------------------------------------------------------------

<tr><td>题目:1+1=?</td></tr>
<tr><td>
<input type=radio name=Question1Answer >1<br>
<input type=radio name=Question1Answer isRight="true">2<br>
<input type=radio name=Question1Answer >3<br>
<input type=radio name=Question1Answer >4<br>
</td></tr>

<tr><td>题目:1+2=?</td></tr>
<tr><td>
<input type=radio name=Question2Answer >1<br>
<input type=radio name=Question2Answer >2<br>
<input type=radio name=Question2Answer isRight="true">3<br>
<input type=radio name=Question2Answer >4<br>
</td></tr>

-----------------------------------------------------------------------
-----------------------------------------------------------------------

TestPaper.htm:
----------------------------------------
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>支持民族工业,尽量少买日货</title>
</head>
<IE:Download ID="oDownload" STYLE="behavior:url(#default#download)" />
<body>
<BR>
<input type=button value="看看成绩" onclick="getScore()">
<table>
<script language=javascript>
oDownload.startDownload('QuestionData1.htm',document.write);
</script>
</table>
</body>

</html>
<script>
function getScore()
{
var theInputs=document.getElementsByTagName("INPUT");
var questionNum=0;
var rightNum=0;
for (var i=0;i<theInputs.length;i++){
if(theInputs[i].isRight)
{
questionNum++;
if(theInputs[i].checked) rightNum++;
}
}
alert("您答对了"+questionNum+"道题中的"+rightNum+"道");
}

</script>

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧