469,572 Members | 1,205 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

update on check


hi
i need to update an SQL Table when user select or unselect a checkbox
control.
How Can i do?
Thanks
Alex

Aug 22 '05 #1
5 2141
A.Dagostino wrote:
hi
i need to update an SQL Table when user select or unselect a checkbox
control.
How Can i do?
Thanks
Alex


Database type and version, please. "SQL Table" may mean "MS SQL Server", but
it does not have to ...
Also, please provide some information about the table. It would really help
if you provided the CREATE TABLE script for the table (www.aspfaq.com/5006).
Just show the relevant columns.

And give us a little information about the form you are using. Are you using
POST or GET? What is the name of the checkbox? Are you submitting it to
itself or to another page?
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Aug 22 '05 #2

the table is a MS SQL Server table
here is the script
<%
'I LOAD A TABLE WITH THE COLUMNS AND A CHECKBOX
response.expires = 0

dim sql, rs
set rs = createObject("ADODB.recordset")
rs.open "USE At_Wrk_Db SELECT IdArticolo, MGAA_MBIV_Id, MGAA_MBDC_Classe,
MGAA_Matricola, descrizione, Statoarticolo, selezione FROM
WRK_ListaArticoli",connessioneDB, 3, 3

response.Write("<input type=""button"" value=""Chiudi finestra""
name=""CloseWin"" onclick=""javascript:chiudifinestra();""</button></td>")
response.write "<table cellspacing=""3"" cellpadding=""2"" border=""1""
rules=""groups"" frame=""borders"" bordercolor=""#cococo""
style=""behavior:url(tabEdit.htm)"" slcolor=silver hlcolor=black>"
'response.write "<table border='1'>"
while not rs.eof
'response.write "<tr style=""cursor: hand;""
onclick=""selectSeekRow(this);"""
response.write "<tr>"
response.write "<td>" & rs("IDarticolo") & "</td>"
response.write "<td>" & rs("MGAA_MBIV_Id") & "</TD>"
'response.write "><td style=""padding-left:3px;border-bottom:1px solid
black;border-right:1px solid black""><font size=""1"">"
response.write "<td>" & rs("MGAA_MBDC_Classe") & "</td>" '&
"</font></td><td style=""border-right:1px solid black;border-bottom:1px
solid black;"">"
response.write "<td>" & rs("MGAA_Matricola") & "</td>" '& "</td><td
style=""padding-left:5px;border-bottom:1px solid black;"">"
response.write "<td>" & rs("descrizione") & "</td>"
style=""border-bottom:1px solid black;"">" & posizione &" </td>"
'I CALL A VBSCRIPT SUB(WHITH PARAMETERS) WHEN THE ONCLICK EVENT IS ACTIVATE
response.write "<td><input type='checkbox' name='ChkSelezione'
onclick=""ChkSelezione_onClick(this.checked," & rs("MGAA_Matricola") &
");""></td>"
response.write "</tr>"
rs.movenext
wend
response.write "</table>"
%>

HERE IS THE SUB

Sub ChkSelezione_onClick(Check, Matricola)
dim Sql_Aggiorna_Sel, bit, rs
//msgbox (chek & " " & Matricola)
if check=true then
bit=1
else
bit=0
End if
Sql_Aggiorna_Sel= "USE At_Wrk_Db UPDATE WRK_ListaArticoli SET Selezione =" &
bit & " WHERE MGAA_Matricola=" & "'" & matricola & "'"
connessioneDB.execute(Sql_Aggiorna_Sel)

end sub

* connessioneDB is defined in the GLOBAL.ASA it seems to be Protected.

thanks for your help
Alex
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ha scritto nel messaggio
news:ex**************@TK2MSFTNGP09.phx.gbl...

A.Dagostino wrote:
hi
i need to update an SQL Table when user select or unselect a checkbox
control.
How Can i do?
Thanks
Alex


Database type and version, please. "SQL Table" may mean "MS SQL Server",
but it does not have to ...
Also, please provide some information about the table. It would really
help if you provided the CREATE TABLE script for the table
(www.aspfaq.com/5006). Just show the relevant columns.

And give us a little information about the form you are using. Are you
using POST or GET? What is the name of the checkbox? Are you submitting it
to itself or to another page?
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


Aug 22 '05 #3
www.aspfaq.com/5006

Bob Barrows
A.Dagostino wrote:
the table is a MS SQL Server table.
What version of SQL Server?
here is the script
<% You misunderstood what I meant by a "CREATE TABLE" script. Please go to the
link I provided and read the article:
www.aspfaq.com/5006
Also, I noticed an onclick event procedure containing some code to create a
sql statement. Does this imply that you want to perform this update from
client-side code without submitting your form? If so, this is not an ASP
issue and you should provide the information I requested in a post to a more
relevant newsgroup like microsoft.public.scripting.vbscript

Bob Barrows

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ha scritto nel
messaggio news:ex**************@TK2MSFTNGP09.phx.gbl...

A.Dagostino wrote:
hi
i need to update an SQL Table when user select or unselect a
checkbox control.
How Can i do?
Thanks
Alex


Database type and version, please. "SQL Table" may mean "MS SQL
Server", but it does not have to ...
Also, please provide some information about the table. It would
really help if you provided the CREATE TABLE script for the table
(). Just show the relevant columns.

And give us a little information about the form you are using. Are
you using POST or GET? What is the name of the checkbox? Are you
submitting it to itself or to another page?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Aug 22 '05 #4

ok i try to explain you my problem from the begin.
I have a page whith n articles loaded in an html table.
Now users can select only one article.
I need to permit a multiselction to the users.
So, if i can't modify the original template I have Created a window whit
the articles and checkbox controls. Now i need to give the result of the
selection to anaother page.

How can i do?
P.S i'm not very espert of web applications
Thanks
Alex
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ha scritto nel messaggio
news:%2****************@TK2MSFTNGP15.phx.gbl...

www.aspfaq.com/5006

Bob Barrows
A.Dagostino wrote:
the table is a MS SQL Server table.


What version of SQL Server?
here is the script
<%

You misunderstood what I meant by a "CREATE TABLE" script. Please go to
the
link I provided and read the article:
www.aspfaq.com/5006


Also, I noticed an onclick event procedure containing some code to create
a
sql statement. Does this imply that you want to perform this update from
client-side code without submitting your form? If so, this is not an ASP
issue and you should provide the information I requested in a post to a
more
relevant newsgroup like microsoft.public.scripting.vbscript

Bob Barrows

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ha scritto nel
messaggio news:ex**************@TK2MSFTNGP09.phx.gbl...

A.Dagostino wrote:
hi
i need to update an SQL Table when user select or unselect a
checkbox control.
How Can i do?
Thanks
Alex

Database type and version, please. "SQL Table" may mean "MS SQL
Server", but it does not have to ...
Also, please provide some information about the table. It would
really help if you provided the CREATE TABLE script for the table
(). Just show the relevant columns.

And give us a little information about the form you are using. Are
you using POST or GET? What is the name of the checkbox? Are you
submitting it to itself or to another page?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


Aug 23 '05 #5
You're telling me everything except what I asked for: I need to know about
your database. I need to know about the columns in your database table (not
all of them - just the relevant ones - the primary key, the field that will
contain the data controlled by the checkbox). Not just their names ... I
need to know their datatypes. Again, the best way to convey that information
can be found in www.aspfaq.com/5006.

From your description, it no longer sounds as if you need a client-side
solution, so we will continue this discussion here. Please provide the
information requested in my first paragraph so I can begin to help you.

Also, I need to know what you want the application to do after the user
clicks the checkboxes in your html table. It is easy enogh to process the
multiple checkbox selections in another page ... I just need to know what
you want that page to do with the records that were selected.

Here is a quick generic demonstration:

page1.htm:

<html><body>
<form method="post" action="page2.asp">
<table>
<tr>
<td>
<input type="text" value="First record" name="data1">
</td>
<td>
<input type="checkbox" name="selector" value="1">
</td>
</tr>
<tr>
<td>
<input type="text" value="Second record" name="data2">
</td>
<td>
<input type="checkbox" name="selector" value="2">
</td>
</tr>
<tr>
<td>
<input type="text" value="Third record" name="data3">
</td>
<td>
<input type="checkbox" name="selector" value="3">
</td>
</tr>
</table>
<input type="submit" value="Submit">
</form>
</body></html>
page2.asp:

<%
dim key
Response.write "Here is all the data submitted by the form:<BR>"
for each key in Request.Form
Response.Write key & ": " & Request.Form(key) & "<BR>"
next

dim selected
selected=request.form("selector")
Response.write "<BR>The following records were selected:<BR>"
Response.write selected & "<BR><BR>"
Response.write "Here is where I process the selections:<BR>"
dim ar, i, id, data
if len(selected) > 0 then
response.write "<table border=""1""><tr><th colspan=""2"">"
response.write "Selected Data" & "</th></tr>"
ar=split(selected,",")
for i = 0 to ubound(ar)
id=trim(ar(i))
data = request.form("data" & id)
ar(i)="<tr><td>" & id & "</td><td>" & data & "</td></tr>"
next
response.write join(ar,vbcrlf)
response.write "</table>"
else
response.write "No records were selected"
end if
%>

Bob Barrows
A.Dagostino wrote:
ok i try to explain you my problem from the begin.
I have a page whith n articles loaded in an html table.
Now users can select only one article.
I need to permit a multiselction to the users.
So, if i can't modify the original template I have Created a window
whit the articles and checkbox controls. Now i need to give the
result of the selection to anaother page.

How can i do?
P.S i'm not very espert of web applications
Thanks
Alex
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ha scritto nel
messaggio news:%2****************@TK2MSFTNGP15.phx.gbl...

www.aspfaq.com/5006

Bob Barrows
A.Dagostino wrote:
the table is a MS SQL Server table.


What version of SQL Server?
here is the script
<%

You misunderstood what I meant by a "CREATE TABLE" script. Please go
to the
link I provided and read the article:
www.aspfaq.com/5006


Also, I noticed an onclick event procedure containing some code to
create a
sql statement. Does this imply that you want to perform this update
from client-side code without submitting your form? If so, this is
not an ASP issue and you should provide the information I requested
in a post to a more
relevant newsgroup like microsoft.public.scripting.vbscript

Bob Barrows

"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> ha scritto nel
messaggio news:ex**************@TK2MSFTNGP09.phx.gbl...

A.Dagostino wrote:
> hi
> i need to update an SQL Table when user select or unselect a
> checkbox control.
> How Can i do?
> Thanks
> Alex

Database type and version, please. "SQL Table" may mean "MS SQL
Server", but it does not have to ...
Also, please provide some information about the table. It would
really help if you provided the CREATE TABLE script for the table
(). Just show the relevant columns.

And give us a little information about the form you are using. Are
you using POST or GET? What is the name of the checkbox? Are you
submitting it to itself or to another page?

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get
a quicker response by posting to the newsgroup.


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Aug 23 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Karaoke Prince | last post: by
2 posts views Thread by joo | last post: by
16 posts views Thread by Philip Boonzaaier | last post: by
5 posts views Thread by Stephen Plotnick | last post: by
6 posts views Thread by Suresh | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.