I’m converting an applet I made into JavaScript (i’m new to it) and am having some troubles. What I’m trying to do is have three textfields filled in. Then, with a click of a button, I want to have certain parts of the inputted text appear in a textarea. Here’s what I have:
[code=html]
<head>
<script type=”text/javascript”>
function do_something(str1,str2,str3)
{
var form1Str1 = form1.field1.value;
var form1Str2 = form1.field2.value;
var form1Str3 = form1.field3.value;
form1.outputArea.value=’Field 1: ‘ + str1 + ‘nField 2: ‘ + str2 + ‘nField 3: ‘ + str3
}
</script>
</head>
<body>
<FORM NAME=”form1″>
<table border=”3″ align=”center” bordercolor=”006600″ bgcolor=”beige”>
<tr>
<td align=”right”>Field 1 <INPUT TYPE=TEXT SIZE=4 NAME=”field1″ MAXLENGTH=3></td>
<td align=”left”><INPUT TYPE=TEXT SIZE=6 MAXLENGTH=5 NAME=”field2″> Field 2</td>
</tr>
<tr>
<td colspan=2 align=”left”>Field 3 <INPUT TYPE=TEXT SIZE=12 MAXLENGTH=11 NAME=”field3″></td>
</tr>
<tr>
<td align=”center” colspan=2><TEXTAREA ID=”outputArea” ROWS=8 COLS=25></TEXTAREA></td>
</tr>
<tr>
<td align=”right”><INPUT TYPE=SUBMIT NAME=”enter” VALUE=”Submit” onClick=”do_something()”></td>
<td align=”left”><INPUT TYPE=RESET NAME=”reset” VALUE=”Reset Fields”></td>
</tr>
</table>
</FORM>
</body>
Does is have anything to do with the form method. I don’t know if I should do anything with the method, whether it be post, get, or something else. Any help will be greatly appreciated.
Edit: I guess it would be helpful to tell you what happens when I run this…nothing. All the fields just end up blank. Is there any way for me to run this function and not have all the fields cleared?