Can I have a link that when clicked displays text inside a textarea?
This is what I have.
<script type="text/javascript">
mybutton: onclick {
document.myform2.mytextfield2.value = "Test";
}
</script>
<form name="myform2">
<input type="button" name="mybutton" value="Go">
<input type="text" name="mytextfield2">
</form>
Please tell me what I got wrong.
The problem is that
mybutton: onclick { ... }is not an executable statement; it’s a fragment of code.There are several ways to fix your code.
1. Declare a function in the script, and declare an
onclickevent handler in the button.OR 2. Give the button an ID, put the script block after the button, and modify the event handler registration code.