Asiafever Publish time 15-8-2007 03:25 PM

Retrieve value in textbox (javascript) to a String in java

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....

shahnazz Publish time 15-8-2007 04:59 PM

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 toretrieve 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...

liverpoolfctv Publish time 16-8-2007 09:04 AM

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..

dune1989 Publish time 12-3-2010 10:18 AM

guys,
do you know how to connect MS SQL 2005 database using javascript?

kmkd Publish time 12-3-2010 01:04 PM

dune aku rasa elok buat tajuk baru weh :D
sebab mysql server lain ngan java. dan aku tak tahu pasal mysql server gak :L

kmkd Publish time 12-3-2010 01:04 PM

dune aku rasa elok buat tajuk baru weh :D
sebab mysql server lain ngan java. dan aku tak tahu pasal mysql server gak :L

dune1989 Publish time 12-3-2010 02:49 PM

orait that a good idea..
i will update later..
Pages: [1]
View full version: Retrieve value in textbox (javascript) to a String in java


ADVERTISEMENT