2013-04-28 57 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