Say I have three buttons and a textarea, when I press a button, I want all the text in the text area replaced by a preset JavaScript variable (so if the variable = "hello", all the text in the textarea will be replaced by "hello" on buton press.) If possible, I would like a confirmation box to appear first (e.g: "Are you sure"? - if you press yes it replaces the ext, if you press no, it doesn't). I need this done for three different buttons. My current HTML: <textarea name="code" class="mainscript" cols="100" rows="50"> <input name="butt1" type="button" value="Button1"><input name="butt2" type="button" value="Button1"><input name="butt3" type="button" value="Button1"> Code (markup): Cheers, BP
add id="code" to the textarea: <textarea name="code" id="code" class="mainscript" cols="100" rows="50"> <input name="butt1" type="button" value="Button1" onclick="document.getElementById('code').value = 'hello';"> you should be able to change the literal "hello" to a variable.