-
Inserting multiple records
i have a form in html which uses textboxes(fieldname=mobilecode) as its input type. upon clicking the submit button, the checked items would add to the user's personal data in my database. here is the code:
sql_send= "insert into tblprofiles
(mobilecode, status)
values ('" & request("chkmcode")
& "' , 'cleared')"
the code works if only one checkbox is marked. but if it exceeds 1, the page gets an error (something like data is truncated). can i really insert n number of "mobilecode" with one similar "status" for all of them? please help. thanks in advance.
-
yo u have to loop through all the checkboxes and execute sql statement for every check box.
-
yes i did try to loop on the checkbox array. i used do while but it did not work. can yo show me an example. pls?
-
please post your code here. let me take a look.
-
=======================================
CODE IN HTML FILE
=======================================
Response.Write "<input type=checkbox name=chkSend value=" & rscontact("celnum")& ">"
========================================
CODE IN ASP FILE
========================================
sql_send= "insert into tbloutgoing (vcmobileno, vcmessage) values ('" & request("chksend") & "' , 'status cleared')"
set conn = server.createobject("adodb.connection")
conn.open strconn
conn.execute (sql_send)
conn.close
set conn=nothing
i tried to count how many records where checked and loop it to the insert command but it won't work either. the code in the asp file goes like this:
n=request("chksend").count
n=0
do while request("chksend").count<>n
[insert command
loop
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|