javascript, Auto insert into input/textarea
Code:
<html>
<head>
<script type="text/javascript">
function writeStuff(theform, theinput, code)
{
var cache = document.theform.theinput.value;
document.theform.theinput.value = cache + " " + code + " ";
document.theform.theinput.focus();
}
</script>
</head>
<body>
<form name="sform" method="post" action="">
<textarea name="message" cols="15" rows="15"></textarea><br /><br />
<input type="button" onClick="writeStuff('sform','message','STRING HERE');" name="" />
</form>
</body>
</html>
My problem when I click the button, it doesnt add 'STRING HERE' to the textarea, this function worked perfectly before I attempted to make it universal with some arguments like theform and theinput, can anyone give me a hint on whats wrong.
Re: javascript, Auto insert into input/textarea
I think:
Code:
var cache = document.forms[theform].elements[theinput].value;
Re: javascript, Auto insert into input/textarea
no, still cant get it to work
Code:
<img onClick="writeStuff(\'eshoutbox\',\'shoutm\',\':sad\')" src="images/smileys/sad.gif" />