Home > Archive > ASP > August 2005 > update on check
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| A.Dagostino 2005-08-22, 7:55 am |
|
hi
i need to update an SQL Table when user select or unselect a checkbox
control.
How Can i do?
Thanks
Alex
| |
| Bob Barrows [MVP] 2005-08-22, 7:55 am |
| 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"
| |
| A.Dagostino 2005-08-22, 7:55 am |
|
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=""java script: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=""selectS Row(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]" <reb01501@NOyahoo.SPAMcom> ha scritto nel messaggio
news:exrbb8wpFHA.3244@TK2MSFTNGP09.phx.gbl...
>
> A.Dagostino wrote:
>
> 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"
>
>
| |
| Bob Barrows [MVP] 2005-08-22, 6:56 pm |
| 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
[color=darkred]
>
> "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> ha scritto nel
> messaggio news:exrbb8wpFHA.3244@TK2MSFTNGP09.phx.gbl...
--
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.
| |
| A.Dagostino 2005-08-23, 7:55 am |
|
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]" <reb01501@NOyahoo.SPAMcom> ha scritto nel messaggio
news:%23cZsK5xpFHA.3064@TK2MSFTNGP15.phx.gbl...
>
> www.aspfaq.com/5006
>
> Bob Barrows
> A.Dagostino wrote:
>
> What version of SQL Server?
>
> 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
>
> --
> 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.
>
>
>
| |
| Bob Barrows [MVP] 2005-08-23, 7:55 am |
| 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:[color=darkred]
> 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]" <reb01501@NOyahoo.SPAMcom> ha scritto nel
> messaggio news:%23cZsK5xpFHA.3064@TK2MSFTNGP15.phx.gbl...
--
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"
|
|
|
|
|