• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 255
  • Last Modified:

Insert values from 10 textboxes with same name in asp

im using classic asp. i have an html form with 10 textboxes with same. can is use one statement to insert all these textbox values into the table.

eg.
Insert into table(name) values (txtbox1).

please help if any solution is available.
0
ayha1999
Asked:
ayha1999
  • 2
1 Solution
 
venkateshwarrCommented:
Yes you can do that, but it is advisable to use diffrenent name.
The following example can help you....

<form method=get>
      <input type=text name=var1 value=hello1>
      <input type=text name=var1 value=hello2>
      <input type=text name=var1 value=hello3>
      <input type='submit'>
</form>

<%
      qstr =  Request("var1")
      Response.write "str =  " & qstr & " <br/>"
      MyArray = split(qstr,",")

                        ' Do database connectins here
      For i=0 to Ubound(MyArray)
              Response.write MyArray(i) & "<br>"
                             'query = "Insert into table(attrname) value(" & MyArray(i) &")"
      Next

%>

0
 
alorentzCommented:
No need to split:

<form method=get>
     <input type=text name=var1 value=hello1>
     <input type=text name=var1 value=hello2>
     <input type=text name=var1 value=hello3>
     <input type='submit'>
</form>

'''''''''''''''''''''''''''''''''''''''''new page

    For each element in request(var1)
             Response.write element & "<br>"
              'sql = "Insert into table(attrname) value(" & element &")"
              'execute sql command
     Next
0
 
SlimshaneeyCommented:
You can also reference the items like so:
request.form("text1")(1)
request.form("text1")(2)
request.form("text1")(3)

this will reference each text box in order from 1 to 10 whan they are all named text1
0
 
alorentzCommented:
Why a "C"?
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now