View: 3233|Reply: 6
|
Retrieve value in textbox (javascript) to a String in java
[Copy link]
|
|
Hi,
Is there anyone that can tell me how to retrieve the value from a textbox or listbox in jsp page to a string (Java)?
I need to retrieve this before pressing the submit button to submit the form. That means after user key in the value, i have the onchange method and call a javascript function. I did manage to pass the value into the js function.
In the form
<input type="text" name="t" value="" >
In the suppchk() function i assigned var a = document.all.t.value ;
I have try the input type="hidden" and request.getParameter but i still get the value Null... (this is what i normally use if i submit the form first before retrieve the value in textbox)
So, is there anyway to assign that var a to a string in java? I know this can't be done directly.
Plz help.... Urgent.... |
|
|
|
|
|
|
|
if you are using JSP, then you may create a servlet which is called when the form is submitted, in the servlet specify doGet or doPost methods to retrieve the information from the form, and to process it appropriately (put it in a java string for example, but in this case its scope is limited to the servlet being called)
but if you said that you need to retrieve the information before pressing the submit button, what event needs to be executed for you to retrieve the value?
sorry kalau jawapan tak clear sebab soalan pun tak berapa clear... especially when you mentioned java, is it JSP ke, servlet ke, JavaBean ke... |
|
|
|
|
|
|
|
tp kalu pakai servlet tuh..
public class javaName extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
public void init(ServletConfig config) throws ServletException {
super.init(config);
}
/**Process the HTTP doGet request.
*/
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {response.setContentType(CONTENT_TYPE);
String strName = request.getParameter("name");
}
}
camtuhla kot lbh kurang.. |
Rate
-
1
View Rating Log
-
|
|
|
|
|
|
|
guys,
do you know how to connect MS SQL 2005 database using javascript? |
|
|
|
|
|
|
|
dune aku rasa elok buat tajuk baru weh
sebab mysql server lain ngan java. dan aku tak tahu pasal mysql server gak |
|
|
|
|
|
|
|
dune aku rasa elok buat tajuk baru weh
sebab mysql server lain ngan java. dan aku tak tahu pasal mysql server gak |
|
|
|
|
|
|
|
orait that a good idea..
i will update later.. |
|
|
|
|
|
|
| |
|