aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes to get value from text box using javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "to get value from text box using javascript" Watch "to get value from text box using javascript" New topic
Author

to get value from text box using javascript

balaji karth
Greenhorn

Joined: Jan 27, 2006
Posts: 8
hi all
i have a jsp page in which i have a textbox.
i like to get the value entered into the textbox and set it to a string variable.

i tried with javascript

eg: String val = document.form1.view.value;
where form1 is the form name;
view is the textbox name;

thank you all,
balaji
pankaj kapoor
Greenhorn

Joined: Sep 22, 2005
Posts: 17
To store value using javascript you have to use

var v = document.form1.view.value;
not
String val = document.form1.view.value;
Arvind Sampath
Ranch Hand

Joined: May 11, 2005
Posts: 144
Hi Balaji,

Why do you want to store the value entered in the textbox in a String variable ? If you want to get the value entered in the text at the server side, use request.getParameter("view") (assuming view is the name of your text box). If you need to get the value entered in the text at the client side go as per Pankaj's advice.

Cheers
Arvind
Niki Nono
Ranch Hand

Joined: Mar 20, 2005
Posts: 256
you will have to make one thing clear in your mind first.

javascript runs at client and jsp runs at server. So values of either are not accessible directly.

JSP ultimately converts to html form, so you can put some jsp variable values in the html which can be used bhy javascript.
But for javascript values to be accessible in jsp, you send it as a part of you post.

Then as Arvind said you use request.getParameter("JAVASCRIPT ELEMENT NAME")
to access the value.


Life called,so here I am.<br />Cheers<br />Niki.:-)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: to get value from text box using javascript
 
Similar Threads
form field's value from a string
mock question
value after posting
Populate form fields from a list of data!
using javascript to get set value of property name with a '.' in it