I am trying to autofill a box by clicking a link (with return false). The function to autofill works with button tag but not in anchor tag - instead of returning false, the click event transitions to the href.
Here is the simplified code. Any help is appreciated.Thanks
<!DOCTYPE html PUBLIC"-// W3C//DTD Xhtml 1.0 Strict//EN"" <html xmlns=" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Untitled Page
</title>
</head>
<script type="text/javascript">
function autofill(frm){
frm.box2.value = 'sample_value';
}
</script>
<body>
<FORM NAME="browse" ACTION="<TMPL_VAR MYURL>/browse_results">
<font size="5">
<b>FIND
</b>
</font>
<hr>
<div class="menu" id="find_block">
<ul>
<li>
<a href="#">DOMAINS
</a>
<ul>
<li>
<a href="#1" onclick="alert('Heading Home!'); return false;">1. alert with link
</a>
</li>
<li>
<a href="#2" onClick="autofill2(this.form); return false;">2. autofill with link
</a>
</li>
</ul>
</li>
</ul>
<input readOnly name="box2"/>
<INPUT TYPE=BUTTON OnClick="autofill(this.form,'2')" VALUE="autofill with button ">
</div>
<br>
<font size="5">
<b>WHERE
</b>
</font>
<hr>
</FORM>
</body>
</html>
Here is the simplified code. Any help is appreciated.Thanks
<!DOCTYPE html PUBLIC"-// W3C//DTD Xhtml 1.0 Strict//EN"" <html xmlns=" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Untitled Page
</title>
</head>
<script type="text/javascript">
function autofill(frm){
frm.box2.value = 'sample_value';
}
</script>
<body>
<FORM NAME="browse" ACTION="<TMPL_VAR MYURL>/browse_results">
<font size="5">
<b>FIND
</b>
</font>
<hr>
<div class="menu" id="find_block">
<ul>
<li>
<a href="#">DOMAINS
</a>
<ul>
<li>
<a href="#1" onclick="alert('Heading Home!'); return false;">1. alert with link
</a>
</li>
<li>
<a href="#2" onClick="autofill2(this.form); return false;">2. autofill with link
</a>
</li>
</ul>
</li>
</ul>
<input readOnly name="box2"/>
<INPUT TYPE=BUTTON OnClick="autofill(this.form,'2')" VALUE="autofill with button ">
</div>
<br>
<font size="5">
<b>WHERE
</b>
</font>
<hr>
</FORM>
</body>
</html>