1

好的,这就是我从你那里得到的,你能检查一下这是否正确吗?我无法从书中所说的内容中编辑大部分内容,所以我猜它必须保持这种格式......希望你能提供帮助

<!DOCTYPE html>
<html>
<head>

<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */

document.getElementById( news ) .innerHTML='newsItem1';

var newsItem1 = "L'AQUILA, ITALY (AP) - L'Aquila's chief prosecutor announced an investigation into allegations of shoddy construcation as workers continued to scour the rubble for people still missing after a devastating earthquake five days ago. http://in.reuters.com/article/idUSWBT01103020090411;

var newsItem2 = "WASHINGTON (Reuters) - President Barack Obama said on Friday the recession-hit US ecomony was showing 'glimmers of hope' despite remaining under strain and promised further steps in coming weeks to tackle the finicial crisis. http://in.reuters.com/article/idUSWBT01103020090411";

var newsItem3 = "(eWeek.com) - Apple is close to hitting 1 billion downloads from its App Store and plans on prize giveaway for whoever downloads the billionth application that includes a MacBook Pro and an iPod Touch. http://www.eweek.com/c/a/application-development/eweek-newsbreak-april-13-2009/";

var newsItem4 = "ALTANTA (AP) - Chipper Jones drove in two runs, including a tiebreaking single, and the Atlanta Braves beat Washington 8-5 on Sunday to hand the Nationals their sixth straight loss to start the season. http://www.newsvine.com/_news/2009/04/11/nationals-8-5?category=sports";



</script>

</head>

<body>

<form action="" name="newsHeadlines" method="get">
</form>

<table style="border: 0; width: 100%">
<tr valign="top">
<td>
<select name="headline" multiple="multiple"
 style="height: 93px">
<option onclick="document.newsHeadlines.news.value=newItem1">Investigation of building standards in quake zone</option>

<option onclick="document.newsHeadlines.news.value=newsItem2">Obama sees signs of economic progress</option>

<option onclick="document.newsHeadlines.news.value=newsItem3">Apple App Downloads Approach 1 Billion</option>

<option onclick="document.newsHeadlines.news.value=newsItem4">Jones, Braves beat winless Nationals 8-5</option>
</select>
</td>

<td>
<textarea id="news" name="news" cols="50" rows="10" 
 style="background-color: transparent"></textarea>
</td>
</tr>
</table>


</body>
</html>

每次我点击“地震区建筑标准调查”时,有人可以帮我解决这个问题,在我创建的文本区域中没有显示任何内容。

4

1 回答 1

0

尽管您的分配可能为时已晚,但我认为我应该指出代码中的一些错误并尝试实现您的意图,即在单击相应的选择选项时显示不同的新闻项目。

  1. document.getElementById( 'news' ).innerHTML='newsItem1'; 应该在声明 id 为“news”的文本框标签之后写入,否则将给出空值。

  2. <option onclick="document.newsHeadlines.news.value=newItem1>中,有一个错字(newItem1应该是newsItem1)并且 onclick 属性值不正确。要正确选择文本框并在其中显示预期的文本,您应该使用以下内容:
    onclick="document.getElementById('name').value=newsItem1".
    对其余选项使用类似的值。
于 2014-05-02T21:38:51.303 回答