Current location: Hot Scripts Forums » Programming Languages » Everything Java » Problem retrieving data from dynamic input field


Problem retrieving data from dynamic input field

Reply
  #1 (permalink)  
Old 12-31-06, 09:45 AM
li_ping li_ping is offline
Newbie Coder
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Problem retrieving data from dynamic input field

How can I get the selected and entered values of a set of radio buttons, checkboxes and textbox? The names of the input fields are generated by using the value in the database and therefore the name is dynamic. I’m not sure of how I can get the values using JS. Any suggestion? The language I’m using is JSP.

Thanks.
Reply With Quote
  #2 (permalink)  
Old 12-31-06, 11:23 AM
King Coder King Coder is offline
Community VIP
 
Join Date: Jan 2006
Posts: 703
Thanks: 0
Thanked 0 Times in 0 Posts
The name being dynamic could pose a problem, but you *should* have the name stored somewhere. How are you dynamically creating the textfield names? If the names are all stored in an array, then you shouldn't have to many problems. You can retreive the value with getParmeter:

<%= request.getParameter("name") %>
__________________
my site
Reply With Quote
  #3 (permalink)  
Old 01-01-07, 02:39 AM
li_ping li_ping is offline
Newbie Coder
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
I've tried to store the names in an array and it works but how can I pass the JSP array's values into a hidden input using JS? I've tried to store it but I didn't get any value.
Reply With Quote
  #4 (permalink)  
Old 01-01-07, 02:56 AM
li_ping li_ping is offline
Newbie Coder
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
FYI, I need to pass the names to servlet
Reply With Quote
  #5 (permalink)  
Old 01-01-07, 08:27 AM
King Coder King Coder is offline
Community VIP
 
Join Date: Jan 2006
Posts: 703
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by li_ping
I've tried to store the names in an array and it works but how can I pass the JSP array's values into a hidden input using JS? I've tried to store it but I didn't get any value.
Why would you need javascript? Stick with JSP.


Quote:
FYI, I need to pass the names to servlet

<FORM METHOD=POST ACTION="http://localhost:8080/test/yourservlet">

Get the methods in the servlet via doPost()
__________________
my site

Last edited by King Coder; 01-01-07 at 08:30 AM.
Reply With Quote
  #6 (permalink)  
Old 01-01-07, 09:17 AM
li_ping li_ping is offline
Newbie Coder
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
I'm not sure on how I can pass the array from my JSP page to servlet.
I've tried <%= request.getParameter("name") %> but it returned null.
I've printed out the values in the array in JSP and made sure that there is some value in it.
I've tried the following in my doPost but to no avail:

Code:
    String name = "";
    String[] nm = new String[100];
    
    survey_id = req.getParameter("survey_id");
    System.out.println("servletParticipate.java.getParameter(): survey_id >>> " +survey_id);
    
    nm[0] = req.getParameter("name[0]");
    System.out.println("servletParticipate.java.getParameter(): nm >>> " +nm[0]);
    
    name = req.getParameter("name");
    System.out.println("servletParticipate.java.getParameter(): name >>> " +name);
Any idea on what's happening?
Thank you.
Reply With Quote
  #7 (permalink)  
Old 01-01-07, 09:51 AM
li_ping li_ping is offline
Newbie Coder
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by King Coder
Why would you need javascript? Stick with JSP.
But I thought I need to store the array into a hidden field before I can retrieve it from my servlet using getParameter?
Reply With Quote
  #8 (permalink)  
Old 01-02-07, 06:55 AM
li_ping li_ping is offline
Newbie Coder
 
Join Date: Dec 2006
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Anyone can help me? It's urgent.
Thanks
Reply With Quote
  #9 (permalink)  
Old 01-02-07, 09:34 AM
King Coder King Coder is offline
Community VIP
 
Join Date: Jan 2006
Posts: 703
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by li_ping
But I thought I need to store the array into a hidden field before I can retrieve it from my servlet using getParameter?
You are using JSP also, right?? Heck, store the array of names in a servlet and call it up and create them from JSP.


Quote:
Anyone can help me? It's urgent.
Thanks
Nothing is urgent for us. We are here on our own time and your problem will not be show anymore attention than anyone elses.
__________________
my site
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Your HelP! Loading Multiple External Text into Multiple Dynamic Text Fields Flash_Boi Flash & ActionScript 2 03-30-06 03:27 PM
ASP upload prob minority ASP 1 06-27-05 08:35 AM
having problem in retrieving data n displaying data from database mathfxr JavaScript 1 11-23-04 12:42 AM
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 10:15 AM


All times are GMT -5. The time now is 05:41 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.