0

hello,
can i check with you all,how do i code to get the parameters from textbox in javascript and pass the parameters to
the servlet after a button is click.

thanks
camilia

2
Contributors
5
Replies
6
Views
8 Years
Discussion Span
Last Post by Thirusha
0

just submit the form to the servlet, then you can use request.getParameter to get the parameters

0

Hi Thirusha,
do you have any example on how do i code the javascript?thanks!:)

regards
camilia

1

I dont have code, since this is very simple, the textbox you are refering to is most probably from a html page. so all you have to do is surround it with form tags, then in the action parameter place the url for the servlet, the button you can either have it as type submit or if it is of type button, add an onlick event then use document.formname.submit;
formname being the name of the form which surrounds the text box.

0

Hi i tried the method that you had said. Did I do anything wrongly?

<form name = "form1" action="http://172.26.144.26:8080/FriendsConnection/AddEventServlet" method="post">
 	Name: <input type="text" name="name" /><br />
  	Date: <input type="text" name="date" /><br />
	Time: <input type="text" name="time" /><br />
	Location: <input type="text" name="location" /><br />
	Message: <input type="text" name="message" /><br />
  <input type="submit" value="Submit" onclick="document.form1.submit"/>
</form>

it still does not work.thanks for your help:)

0

You dont put the full url in the action parameter unless you are submitting to a different server, if it is on the same server then

action="FriendsConnection/AddEventServlet"

should suffice, but i am not sure how the servlet is accessed (this depends on your servlet mapping parameter in the web.xml file), so it could be the action as specified above or just "AddEventServlet"

Also if u have a submit type button there is no need for an onclick event.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.