This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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

to get value from text box using javascript

balaji karth

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,
pankaj kapoor

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

var v = document.form1.view.value;
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.

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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: to get value from text box using javascript
It's not a secret anymore!