2013-04-28 39 views
0

单击其中一个单选按钮时,底部的链接应该会更改。我验证了网页,没有错误。我校对了我的Javascript代码,并且没有错。我应该使用另一种DOCTYPE吗?为什么我的Javascript核心不能正常工作?

<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> 

回答

7

有拼写错误udpateInvestmentLinkupdateInvestmentLink,p和d函数定义

function updateInvestmentLink(urlText, urlValue) { 
     document.getElementById('recommendedInvestment').innerHTML = urlText + " (Yahoo! Finance)"; 
     document.getElementById('recommendedInvestment').href = urlValue; 
} 
+0

感谢你交换! :哦,我没看到 – 2013-04-28 16:09:59

相关问题