0

当您单击其中一个单选按钮时,底部的链接应该会发生变化。我验证了网页并且没有错误。我校对了我的 Javascript 代码,没有任何问题。我应该使用另一个 DOCTYPE 吗?

<script type="text/javascript">
/* <![CDATA[ */
function udpateInvestmentLink(urlText, urlValue) {
      document.getElementById('recommendedInvestment').innerHTML = urlText + " (Yahoo! Finance)";
      document.getElementById('recommendedInvestment').href = urlValue;
}
/* ]]> */
</script>
</head>
<body>
<form action="" enctype="application/x-www-form-urlencoded">
<p>
<input type="radio" name="industry" onclick="updateInvestmentLink('Gold', 'http://finance.yahoo.com/q?s=^YH0h714')" />Basic Materials<br />
<input type="radio" name="industry" onclick="updateInvestmentLink('General Electric Industries Ltd.', 'http://finance.yahoo.com/q/pr?s=ge')" />Conglomerates<br />
<input type="radio" name="industry" onclick="updateInvestmentLink('Tyson Foods Inc.', 'http://finance.yahoo.com/q/pr?s=tsn')" />Consumer Foods<br />
<input type="radio" name="industry" onclick="updateInvestmentLink('Catalyst Health Solutions', 'http://finance.yahoo.com/q/pr?s=chsi')" />Financial<br />
<input type="radio" name="industry" onclick="updateInvestmentLink('Genentech Inc.', 'http://finance.yahoo.com/q/pr?s=dna')" />Healthcare<br />
<input type="radio" name="industry" onclick="updateInvestmentLink('Toll Brothers', 'http://finance.yahoo.com/q/pr?s=tol')" />Industrial Goods<br />
<input type="radio" name="industry" onclick="updateInvestmentLink('Sinclair Broadcast Group Inc.', 'http://finance.yahoo.com/q/pr?=sbgi')" />Services<br />
<input type="radio" name="industry" onclick="updateInvestmentLink('Verizon Communications Inc.', 'http://finance.yahoo.com/q/pr?s=vz')" />Technology<br />
<input type="radio" name="industry" onclick="updateInvestmentLink('Northwest Natural Gas Co.', 'http://finance.yahoo.com/q/pr?s=nwn')" />Utilities</p>
</form>
<p><a href="http://finance.yahoo.com/" id="recommendedInvestment">Yahoo! Finance</a></p>
4

1 回答 1

7

有一个拼写错误udpateInvestmentLinkupdateInvestmentLink并且在函数定义中交换了 p 和 d

function updateInvestmentLink(urlText, urlValue) {
      document.getElementById('recommendedInvestment').innerHTML = urlText + " (Yahoo! Finance)";
      document.getElementById('recommendedInvestment').href = urlValue;
}
于 2013-04-28T16:05:12.833 回答