Reputation: 25
Recently I study html and javascript. I know that in html form sends data to server between and .
However, in my case it doesn't.
here is my code
function wReply() {
if(document.getElementById("repInputContent").value == "") {
alert("type anything for reply");
document.getElementById("repInputContent").focus();
return;
}
document.reply.submit();
}
this is javascript function that work with input type button.
And this is html form code
<tr id="replyInput">
<td colspan="3">
<form action="/wReply" accept-charset="utf-8" name="reply" method="post">
<input type="hidden" name="num" value="<%=num%>">
<input type="hidden" name="writer" value="<%=writer%>">
<input type="hidden" name="page" value="<%=page%>">
<textarea rows="4" cols="40" id="repInputContent"></textarea>
</form>
</td>
<td><input type="button" value="submit" onclick="wReply()"></td>
</tr>
I code a table and want to send hidden type datas and textarea data. I think it works but actually server can receive hidden type datas.
What is the problem?
Upvotes: 1
Views: 2099
Reputation: 5036
Wrap your function wReply(){ ... }
is inside body
tag instead of head
! Then
Submit button sends data correctly.
As I have tried it myself;
Head
of the form.
function wReply(){ ... }
is inside body
of the form!Upvotes: 0
Reputation: 1727
Your textarea needs a name.
<textarea rows="4" cols="40" id="repInputContent" name="repInputContent"></textarea>
That'll fix you up.
Upvotes: 1