I've been trying to figure this out for the past 3 hours or so but I can't find the answer anywhere. What I'm trying to do is change the onclick event of a link dynamically using the onclick event of a radio button. Is this even possible? My code looks something like this..
<input type="radio" name="test" onclick="document.getElementById('submit').onclick='alert(\'Hello\');'">First<br/>
<input type="radio" name="test" onclick="document.getElementById('submit').onclick='alert(\'Hi\');'">Second<br/>
<a id="submit" onclick="" href="index.html">Click Here</a>
try this :
<input type="radio" name="test" onclick="document.getElementById('submit').onclick=function(){alert('Hello');}">First<br/>
<input type="radio" name="test" onclick="document.getElementById('submit').onclick=function(){alert('Hi');}">Second<br/>
<a id="submit" onclick="" href="index.html">Click Here</a>
fiddle: http://jsfiddle.net/kfpzY/