Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: how loop data save ?

Results 1 to 4 of 4
Share This Thread →
  1. #1
    MRRaja's Avatar
    MRRaja is offline Contributing User
    Join Date
    Apr 2010
    Location
    Tezpur
    Posts
    218
    Rep Power
    5

    how loop data save ?

    How do I Save This In Table ?

    Code:
    <!-- Form -->
    <form method="POST" action="save.asp">
    	<table border="1" width="100%">
    <%	
    num=0
    Do while Not oRs1.eof=true 
    num=num+1
    %>
    <tr>
    <td><input type="text" name="<%=num+1%>" size="20" value="<%=oRs1("RoolNumber")%>"></td>
    <td><input type="text" name="NAME<%=num+1%>" size="20" value="<%=oRs1("NAME")%>"></td>
    </tr>
    <%
    oRs1.MoveNext  		
    Loop 
    %>
    </table>
    	<input type="submit" value="Submit" name="B1">
    </form>
    <!-- Form Close -->
    i have unknown num as result

    if i have 100 or 200 how do i save this all records in new table with Name and roolnumber

    coz each time page generate more forms/input field with unique name and roolnumber
    if you found this post is useful click (right side on this reply ) and agree

  2. #2
    markoc's Avatar
    markoc is offline Contributing User
    Join Date
    Nov 2003
    Location
    UK
    Posts
    2,280
    Rep Power
    310
    Hi MRRaja,

    I think you need to explain yourself further.
    What are you trying to archive as your end process?
    Hope this advise helps.

    If so please show your appreciation by adding reputation points (click gauge image on top right of this post and score).

  3. #3
    gk53's Avatar
    gk53 is offline Contributing User
    Join Date
    Mar 2005
    Location
    Columbus, OH
    Posts
    1,535
    Rep Power
    278
    first at all add hidden field with items number like that
    Code:
    <!-- Form -->
    <form method="POST" action="save.asp">
    	<table border="1" width="100%">
    <%	
    num=0
    Do while Not oRs1.eof=true 
    num=num+1
    %>
    <tr>
    <td><input type="text" name="<%=num+1%>" size="20" value="<%=oRs1("RoolNumber")%>" /></td>
    <td><input type="text" name="NAME<%=num+1%>" size="20" value="<%=oRs1("NAME")%>" /></td>
    </tr>
    <%
    oRs1.MoveNext  		
    Loop 
    %>
    </table>
        <input type="hidden" name="items" value="<%=num %>" />
    	<input type="submit" value="Submit" name="B1" />
    </form>
    <!-- Form Close -->
    and save page will be something like

    Code:
    set rs= server.CreateObject("adodb.recordset")
    for i=1 to request("items")
        if request("i")<>"" and request("NAME" & i)<>"" then
            sql="select * from yourTable where RoolNumber = '" & request("i") & "'"
            rs.open sql , yourConnection,1,3
            if rs.eof then rs.addnew
            rs("RoolNumber")=request("i")
            rs("NAME")=request("NAME" & i)
            rs.update
            rs.close
        end if
    next
    I did not include code for open connection to database
    GK
    __________________________________________________ _____
    if you found this post is useful click Give Rep button (bottom side on this reply ) and agree

  4. #4
    MRRaja's Avatar
    MRRaja is offline Contributing User
    Join Date
    Apr 2010
    Location
    Tezpur
    Posts
    218
    Rep Power
    5
    GK U R Gr8
    Thanks....

    And Thanks u 2 Markoc

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

Similar Threads

  1. Constructing data using nested for loop
    By freeforum.all in forum ASP Development
    Replies: 1
    Last Post: September 12th, 2010, 05:17 AM
  2. Create new data, find old data, update old data, save both
    By hawzmolly in forum Microsoft Access Help
    Replies: 1
    Last Post: October 11th, 2008, 12:32 PM
  3. Loop and bring the data.
    By Khrysller in forum ASP Development
    Replies: 17
    Last Post: June 30th, 2007, 03:20 PM
  4. How to use the for loop to display all the data in database?
    By sweehin18 in forum ASP Development
    Replies: 6
    Last Post: September 22nd, 2006, 10:11 AM
  5. Loop through textboxes and collect data
    By webb in forum ASP Development
    Replies: 4
    Last Post: June 9th, 2006, 03:51 AM

ASP Free Advertisers and Affiliates