CARI Infonet

 Forgot password?
 Register

ADVERTISEMENT

View: 3139|Reply: 6

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

[Copy link]
Post time 15-8-2007 03:25 PM | Show all posts |Read mode
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....
Reply

Use magic Report


ADVERTISEMENT


Post time 15-8-2007 04:59 PM | Show all posts
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...
Reply

Use magic Report

Post time 16-8-2007 09:04 AM | Show all posts
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

Reply

Use magic Report

Post time 12-3-2010 10:18 AM | Show all posts
guys,
do you know how to connect MS SQL 2005 database using javascript?
Reply

Use magic Report

Post time 12-3-2010 01:04 PM | Show all posts
dune aku rasa elok buat tajuk baru weh
sebab mysql server lain ngan java. dan aku tak tahu pasal mysql server gak
Reply

Use magic Report

Post time 12-3-2010 01:04 PM | Show all posts
dune aku rasa elok buat tajuk baru weh
sebab mysql server lain ngan java. dan aku tak tahu pasal mysql server gak
Reply

Use magic Report

Follow Us
Post time 12-3-2010 02:49 PM | Show all posts
orait that a good idea..
i will update later..
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CARI Infonet

29-4-2024 01:41 AM GMT+8 , Processed in 0.074782 second(s), 37 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list