Yes another checkbox question

Yes another checkbox question

am 05.01.2005 23:08:12 von Marco Krechting

Hi All,

I have an asp page which displays the content of a table from a db.
Every record has 4 checkboxes to it. Some checked some not, depending of the
db.

if rst("ARR101") = "True" then
.Write " countIt &" CHECKED>"
else
.Write " countIt &">"
end if

This all works fine but now the user must check some additional boxes and
click the Update button
which will then open the Update.asp page and the database has to be updated
with the new values
of the checkboxes.

Value1 = Request.Form("ARR101"& i)
If Value1 <> 1 Then
Value1 = 0
End If

strSQL = "Update [SID_Master_Archief] Set [ARR101] = " & Value1 & ",
[ARR103] = " & Value2 & ", [ARR104] = " & Value3 & ", [ARR105] = " & Value4
& " where [PK] = " & myPK

This will however never work since Value1 will always be the old value when
the recordset was created on the first page.
In other words it will not identify me clicking a checkbox to ON.

How can I get this fixed?

Regards

Marco

Re: Yes another checkbox question

am 06.01.2005 09:35:19 von exjxw.hannivoort

Marco Krechting wrote on 05 jan 2005 in microsoft.public.inetserver.asp.db:

> if rst("ARR101") = "True" then
> .Write " > countIt &" CHECKED>"
> else
> .Write " > countIt &">"
> end if
>

Sideline:


<% if rst("ARR101") then response.write " CHECKED" %>
>




--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Re: Yes another checkbox question

am 06.01.2005 16:41:09 von Mark Schupp

Response.Write " countIt
If rst("ARR101") = "True" then
Response.Write " CHECKED"
End If
Response.Write ">"

in your form processing:

Value1 = Request.Form("ARR101"& i)
If Value1 <> "1" Then
Value1 = 0
Else
Value1 = 1
End If

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com


"Marco Krechting" wrote in message
news:792a1$41dc653f$3e3af2ad$19848@news1.versatel.nl...
> Hi All,
>
> I have an asp page which displays the content of a table from a db.
> Every record has 4 checkboxes to it. Some checked some not, depending of
the
> db.
>
> if rst("ARR101") = "True" then
> .Write " > countIt &" CHECKED>"
> else
> .Write " > countIt &">"
> end if
>
> This all works fine but now the user must check some additional boxes and
> click the Update button
> which will then open the Update.asp page and the database has to be
updated
> with the new values
> of the checkboxes.
>
> Value1 = Request.Form("ARR101"& i)
> If Value1 <> 1 Then
> Value1 = 0
> End If
>
> strSQL = "Update [SID_Master_Archief] Set [ARR101] = " & Value1 & ",
> [ARR103] = " & Value2 & ", [ARR104] = " & Value3 & ", [ARR105] = " &
Value4
> & " where [PK] = " & myPK
>
> This will however never work since Value1 will always be the old value
when
> the recordset was created on the first page.
> In other words it will not identify me clicking a checkbox to ON.
>
> How can I get this fixed?
>
> Regards
>
> Marco
>
>

Re: Yes another checkbox question

am 06.01.2005 19:03:53 von Marco Krechting

Thanks Mark,

But that doesn't work.
I already tried it. You see the value will not change when I click the
checkbox. It will remain 1.
So when you Request.form you will never get for example Value=0 even if I
have unchecked the checkbox.

Regards
Marco

"Mark Schupp" wrote in message
news:%23JzYJaA9EHA.824@TK2MSFTNGP11.phx.gbl...
> Response.Write " > name=ARR101"&
> countIt
> If rst("ARR101") = "True" then
> Response.Write " CHECKED"
> End If
> Response.Write ">"
>
> in your form processing:
>
> Value1 = Request.Form("ARR101"& i)
> If Value1 <> "1" Then
> Value1 = 0
> Else
> Value1 = 1
> End If
>
> --
> Mark Schupp
> Head of Development
> Integrity eLearning
> www.ielearning.com
>
>
> "Marco Krechting" wrote in message
> news:792a1$41dc653f$3e3af2ad$19848@news1.versatel.nl...
>> Hi All,
>>
>> I have an asp page which displays the content of a table from a db.
>> Every record has 4 checkboxes to it. Some checked some not, depending of
> the
>> db.
>>
>> if rst("ARR101") = "True" then
>> .Write " >> countIt &" CHECKED>"
>> else
>> .Write " >> countIt &">"
>> end if
>>
>> This all works fine but now the user must check some additional boxes and
>> click the Update button
>> which will then open the Update.asp page and the database has to be
> updated
>> with the new values
>> of the checkboxes.
>>
>> Value1 = Request.Form("ARR101"& i)
>> If Value1 <> 1 Then
>> Value1 = 0
>> End If
>>
>> strSQL = "Update [SID_Master_Archief] Set [ARR101] = " & Value1 & ",
>> [ARR103] = " & Value2 & ", [ARR104] = " & Value3 & ", [ARR105] = " &
> Value4
>> & " where [PK] = " & myPK
>>
>> This will however never work since Value1 will always be the old value
> when
>> the recordset was created on the first page.
>> In other words it will not identify me clicking a checkbox to ON.
>>
>> How can I get this fixed?
>>
>> Regards
>>
>> Marco
>>
>>
>
>

Re: Yes another checkbox question

am 06.01.2005 20:44:05 von Robert Mark Bram

It should.

Did you notice that Mark's code removed the conditional check, and only has
one checkbox possibility with the value of 1?

If it is unchecked by the user and then submitted, request.form("ARR101"& i)
will be equal to "", which is not 1, so the value 0 will be assigned to
Value1.

Bob Lehmann

"Marco Krechting" wrote in message
news:2af4f$41dd7d7b$3e3af2ad$17099@news1.versatel.nl...
> Thanks Mark,
>
> But that doesn't work.
> I already tried it. You see the value will not change when I click the
> checkbox. It will remain 1.
> So when you Request.form you will never get for example Value=0 even if I
> have unchecked the checkbox.
>
> Regards
> Marco
>
> "Mark Schupp" wrote in message
> news:%23JzYJaA9EHA.824@TK2MSFTNGP11.phx.gbl...
> > Response.Write " > > name=ARR101"&
> > countIt
> > If rst("ARR101") = "True" then
> > Response.Write " CHECKED"
> > End If
> > Response.Write ">"
> >
> > in your form processing:
> >
> > Value1 = Request.Form("ARR101"& i)
> > If Value1 <> "1" Then
> > Value1 = 0
> > Else
> > Value1 = 1
> > End If
> >
> > --
> > Mark Schupp
> > Head of Development
> > Integrity eLearning
> > www.ielearning.com
> >
> >
> > "Marco Krechting" wrote in message
> > news:792a1$41dc653f$3e3af2ad$19848@news1.versatel.nl...
> >> Hi All,
> >>
> >> I have an asp page which displays the content of a table from a db.
> >> Every record has 4 checkboxes to it. Some checked some not, depending
of
> > the
> >> db.
> >>
> >> if rst("ARR101") = "True" then
> >> .Write " > >> countIt &" CHECKED>"
> >> else
> >> .Write " > >> countIt &">"
> >> end if
> >>
> >> This all works fine but now the user must check some additional boxes
and
> >> click the Update button
> >> which will then open the Update.asp page and the database has to be
> > updated
> >> with the new values
> >> of the checkboxes.
> >>
> >> Value1 = Request.Form("ARR101"& i)
> >> If Value1 <> 1 Then
> >> Value1 = 0
> >> End If
> >>
> >> strSQL = "Update [SID_Master_Archief] Set [ARR101] = " & Value1 & ",
> >> [ARR103] = " & Value2 & ", [ARR104] = " & Value3 & ", [ARR105] = " &
> > Value4
> >> & " where [PK] = " & myPK
> >>
> >> This will however never work since Value1 will always be the old value
> > when
> >> the recordset was created on the first page.
> >> In other words it will not identify me clicking a checkbox to ON.
> >>
> >> How can I get this fixed?
> >>
> >> Regards
> >>
> >> Marco
> >>
> >>
> >
> >
>
>

Re: Yes another checkbox question

am 06.01.2005 21:03:34 von Mark Schupp

Checkboxes do not change values when they are checked. They either send the
specified value if checked or send no value at all. In your original code
you would have gotten a value of "0" if the user checked a box that had not
been set to "checked" by your code.

Another problem with your original code is that all form element values are
strings. The comparison:

Value1 <> 1

will always return True. You need to compare the form value with the string
"1" not the number 1. This is probably what was throwing you off originally.

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com


"Marco Krechting" wrote in message
news:2af4f$41dd7d7b$3e3af2ad$17099@news1.versatel.nl...
> Thanks Mark,
>
> But that doesn't work.
> I already tried it. You see the value will not change when I click the
> checkbox. It will remain 1.
> So when you Request.form you will never get for example Value=0 even if I
> have unchecked the checkbox.
>
> Regards
> Marco
>
> "Mark Schupp" wrote in message
> news:%23JzYJaA9EHA.824@TK2MSFTNGP11.phx.gbl...
> > Response.Write " > > name=ARR101"&
> > countIt
> > If rst("ARR101") = "True" then
> > Response.Write " CHECKED"
> > End If
> > Response.Write ">"
> >
> > in your form processing:
> >
> > Value1 = Request.Form("ARR101"& i)
> > If Value1 <> "1" Then
> > Value1 = 0
> > Else
> > Value1 = 1
> > End If
> >
> > --
> > Mark Schupp
> > Head of Development
> > Integrity eLearning
> > www.ielearning.com
> >
> >
> > "Marco Krechting" wrote in message
> > news:792a1$41dc653f$3e3af2ad$19848@news1.versatel.nl...
> >> Hi All,
> >>
> >> I have an asp page which displays the content of a table from a db.
> >> Every record has 4 checkboxes to it. Some checked some not, depending
of
> > the
> >> db.
> >>
> >> if rst("ARR101") = "True" then
> >> .Write " > >> countIt &" CHECKED>"
> >> else
> >> .Write " > >> countIt &">"
> >> end if
> >>
> >> This all works fine but now the user must check some additional boxes
and
> >> click the Update button
> >> which will then open the Update.asp page and the database has to be
> > updated
> >> with the new values
> >> of the checkboxes.
> >>
> >> Value1 = Request.Form("ARR101"& i)
> >> If Value1 <> 1 Then
> >> Value1 = 0
> >> End If
> >>
> >> strSQL = "Update [SID_Master_Archief] Set [ARR101] = " & Value1 & ",
> >> [ARR103] = " & Value2 & ", [ARR104] = " & Value3 & ", [ARR105] = " &
> > Value4
> >> & " where [PK] = " & myPK
> >>
> >> This will however never work since Value1 will always be the old value
> > when
> >> the recordset was created on the first page.
> >> In other words it will not identify me clicking a checkbox to ON.
> >>
> >> How can I get this fixed?
> >>
> >> Regards
> >>
> >> Marco
> >>
> >>
> >
> >
>
>

Re: Yes another checkbox question

am 06.01.2005 21:57:58 von Marco Krechting

Bob,

mea culpa, you were right It does work.
The problem is my query is not getting the right values to update the
database.

strSQL = "Update [SID_Master_Archief] Set [ARR101] = " & Value1 & ",
[ARR103] = " & Value2 & ", [ARR104] = " & Value3 & ", [ARR105] = " & Value4
& " where [PK] = " & myPK

If I do like this:

response.write(Value1)
response.write(Value2)
response.write(Value3)
response.write(Value4)
next

Then I do get the right list of zero and one.

Marco

"Bob Lehmann" wrote in message
news:uxAy8fC9EHA.2124@TK2MSFTNGP14.phx.gbl...
> It should.
>
> Did you notice that Mark's code removed the conditional check, and only
> has
> one checkbox possibility with the value of 1?
>
> If it is unchecked by the user and then submitted, request.form("ARR101"&
> i)
> will be equal to "", which is not 1, so the value 0 will be assigned to
> Value1.
>
> Bob Lehmann
>
> "Marco Krechting" wrote in message
> news:2af4f$41dd7d7b$3e3af2ad$17099@news1.versatel.nl...
>> Thanks Mark,
>>
>> But that doesn't work.
>> I already tried it. You see the value will not change when I click the
>> checkbox. It will remain 1.
>> So when you Request.form you will never get for example Value=0 even if I
>> have unchecked the checkbox.
>>
>> Regards
>> Marco
>>
>> "Mark Schupp" wrote in message
>> news:%23JzYJaA9EHA.824@TK2MSFTNGP11.phx.gbl...
>> > Response.Write " >> > name=ARR101"&
>> > countIt
>> > If rst("ARR101") = "True" then
>> > Response.Write " CHECKED"
>> > End If
>> > Response.Write ">"
>> >
>> > in your form processing:
>> >
>> > Value1 = Request.Form("ARR101"& i)
>> > If Value1 <> "1" Then
>> > Value1 = 0
>> > Else
>> > Value1 = 1
>> > End If
>> >
>> > --
>> > Mark Schupp
>> > Head of Development
>> > Integrity eLearning
>> > www.ielearning.com
>> >
>> >
>> > "Marco Krechting" wrote in message
>> > news:792a1$41dc653f$3e3af2ad$19848@news1.versatel.nl...
>> >> Hi All,
>> >>
>> >> I have an asp page which displays the content of a table from a db.
>> >> Every record has 4 checkboxes to it. Some checked some not, depending
> of
>> > the
>> >> db.
>> >>
>> >> if rst("ARR101") = "True" then
>> >> .Write " >> >> name=ARR101"&
>> >> countIt &" CHECKED>"
>> >> else
>> >> .Write " >> >> name=ARR101"&
>> >> countIt &">"
>> >> end if
>> >>
>> >> This all works fine but now the user must check some additional boxes
> and
>> >> click the Update button
>> >> which will then open the Update.asp page and the database has to be
>> > updated
>> >> with the new values
>> >> of the checkboxes.
>> >>
>> >> Value1 = Request.Form("ARR101"& i)
>> >> If Value1 <> 1 Then
>> >> Value1 = 0
>> >> End If
>> >>
>> >> strSQL = "Update [SID_Master_Archief] Set [ARR101] = " & Value1 & ",
>> >> [ARR103] = " & Value2 & ", [ARR104] = " & Value3 & ", [ARR105] = " &
>> > Value4
>> >> & " where [PK] = " & myPK
>> >>
>> >> This will however never work since Value1 will always be the old value
>> > when
>> >> the recordset was created on the first page.
>> >> In other words it will not identify me clicking a checkbox to ON.
>> >>
>> >> How can I get this fixed?
>> >>
>> >> Regards
>> >>
>> >> Marco
>> >>
>> >>
>> >
>> >
>>
>>
>
>