首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我的赋值确实需要一些变量声明方面的帮助

我的赋值确实需要一些变量声明方面的帮助
EN

Stack Overflow用户
提问于 2013-10-09 03:08:47
回答 1查看 82关注 0票数 1

好的,这是我从你那里得到的东西,你能检查一下这是否正确吗?我不能对书中的大部分内容进行编辑,所以它必须保持这种格式,im guessing..hope,你可以帮上忙

代码语言:javascript
复制
<!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>

有人能帮我解决这个问题吗?每次我点击“地震灾区建筑标准调查”时,我创建的文本区都没有显示任何内容。

EN

回答 1

Stack Overflow用户

发布于 2014-05-03 05:38:51

尽管对你的任务来说可能太晚了,但我认为我应该指出代码中的一些错误,并尝试实现你想要的东西,即在单击相应的选择选项时显示不同的newsItems。

新闻应在声明id为‘

  1. document.getElementById( 'news' ).innerHTML='newsItem1';’的textbox标记之后写入,否则将提供空值。

  1. <option onclick="document.newsHeadlines.news.value=newItem1>中,有一个拼写错误(newItem1应该是newsItem1),并且onclick属性值不正确。要正确选择文本框并在其中显示所需的文本,应使用以下方法:

onclick="document.getElementById('name').value=newsItem1"

对其余选项使用相似的值。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19256216

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档