Hi.... I have this form in which if there are 10 rows then thier would be 10 textboxes and 10 combo box ..... now i'm using a javascrpit for displaying a calendar and when ever i select a date it goes into the respective text boxes.... the problem that i'm facing is that ... in my while loop i have a string textname whose value is "txt + Integer.toString(i)" ...the value of "i" is incremented on the number of records that are retreived ..so if 10 records are there then the vale of "i" will be incremented till 10 ... and this textname is the name of my textbox in which the date is displayed..... . so it's like <td width="12%" height="34" align="left" bgcolor="#ECEFF2"><b><font face="Verdana" size="2"> </font></b><font color="#2F7391"><input type="text" name="<%=textname%>" size="9"></font> as u can see from the above code that textbox name is = <%=textname%> ..... i need to keep the name of my textbox dynamic inorder to refelct the values from the calendar ...... can some one plz tell me ....... when i submit my form ..... suppose i have 10 rows ... then how can i retrieve all the 10 values of the textboxes ..... plz keep in mind that i don't have a fixed name from my textbox .... it's <%=textname%> ... so if i have 10 records.... the names would be iterating from txt1,txt2 ......txt10 !!! so what should i write in the request.getparameter("???"); so that all my records can be retreived as an array ...??? or if any one has any other idea of getting all values from the textbox ..plz let me know...!!! thanx .. :roll:
Hi AruCh You will have to "know" how many text fields where there in the servlet where you might be submitting the request and then apply the same logic to determine names of the text fields as you are doing in the JSP where those text fields are rendered. So, if in JSP you are doing, textname = "txt"+loopIndex; then pass this count of text fields in one other field of the form to the servlet and then in servlet write, textname= "txt"+loopIndex; request.getParameter(textname); in a loop you know... Basically, "we have to pass the count of textfields to the servlet and reform the naming of the text fields to get values of each" Hope I'm not confusing you. Regards Maulin
Joined: Oct 08, 2003
hi... thanz maulin ..... for sharing ur idea with me ... .... But can u help me out on one more thing.... now that u can see i have 10 different data in these 10 textboxes ..... now i want to update all the 10 textboxes through ONE update button ..... So its like i have a unique id field ... as IdNumber .... and for these idnumber i'm entering values in the text box as well as combo boxes.... if there would be only one text box called date and one combo box named class then my update statement would be ... (Update <tablename> set date = '"+date+"',class ='"+class+"' where idnumber = '"+idNumber+"') but now the problem is that i have more than 1 data for both the date textbox and class combo box ... so how would i go bout the updating of the records ...... Example IDnumber TextboxDate ClassCombobox 123 2003-10-15 abc 124 2003-20-10 fff 128 2003-09-03 kkk so now ..... for each idnumber i have to update the database with the date feild and combo box .... how would i do that ..... plz keep in mind that all this has to be done ... on one sumbit button/update button which calls another jsp ...... now retreiving the values is not a problem ... updating the values corresponding to the idnumber is a problem ....
I hope u have got the idea .....!!! Plz if any one else can help .... i would be very thankful If possible ..... please try and include a sample code Thanxsssss
Welcome to the Ranch AruCh! You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it. Thanks! bear JSP Fourm Bartender [ October 19, 2003: Message edited by: Bear Bibeault ]