Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating checkbox values

Status
Not open for further replies.

moley

IS-IT--Management
Mar 26, 2002
95
GB
Anyone, this is driving me mad.
I have an input form with 5 checkboxes. the form writes to a sql database(the fields are bit)
I then retrieve the data on another form (to amend )
The problem is I cant get any new checkbox values to write back to the database. I managed to get the boxes to display checked or unchecked but if the user checks the box, I still get the old value.


sample code for the checkbox

<input type=&quot;checkbox&quot; name=&quot;mon&quot; value =&quot;<%=rs(&quot;mon&quot;)%>&quot; <%If rs(&quot;mon&quot;)= &quot;true&quot; then response.write(&quot;CHECKED&quot;) end if%>>

It probably really obvious but can anyone help me with the code???

Cheers

moley
 
so you want the checkbox's disabled in the second form?

____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
no i want to change the checkboxes on the second form.

eg i work on days (mon tue wed thur fri) each has a checkbox (1st form)
i change to part time, so i want to open the second form, view the days previously checked then uncheck (mon tue wed). then write back to the database.
 
so you have the first form in which the user clicks the given days (or auto populates) as checkbox's
say ( ()=checkbox)
() Mon () Tue () Wed () Thur () Fri

so say they check Mon and Tue, you insert this into the DB as
Mon=True, Tue=True, Wed=False, Thur=False, Fri=False

now the second form is loaded and SELECT's the values to populate the checkbox's given a checked value if the DB output = True.

At this point the user can edit the values.
say they check Wed and leave everything left alone as is then.
So basically run your INSERT again but make it a UPDATE. you will need some sort of ID (Key field) to validate the correct row to update.

Is this a group of checkbox's or are they uniquly named?


____________________________________________________
The most important part of your thread is the subject line.
Make it clear and about the topic so we can find it later for reference. Please!! faq333-3811

onpnt2.gif
 
the checkboxes are uniquely named. the updates fine, but the values posted from the second form are the old values from the first form regardless of which days are checked.
 
MY CHECKBOXES ARE ALL UNIQUE, NAMED MON, TUE, ETC. SO I DONT NEED AN ID. IF I UNCHECK A CHECKED BOX THE ORIGINAL VALUE POSTS.(=&quot;<%=rs(&quot;mon&quot;)%>&quot; )
ANY IDEAS WITHOUT AN ARRAY??
 
The problem is this:
Code:
If rs(&quot;mon&quot;)= &quot;true&quot; Then
With a bit value in SQL Server that will never evaluate to true because
Code:
&quot;true&quot;
is a string consisting of:
Code:
t
r
u
e
and there's no way a 0 or a 1 will be equal to that. Rather you want to know:
Code:
If rs(&quot;mon&quot;)= True Then
or more simply you can just put
Code:
If rs(&quot;mon&quot;) Then
 
thanks for the input, but i've managed to fix the problem. I was being a brain dead zombie. I shouldt have been setting the value to rs(blah). set all value to true and it works .

Thanks anyway

Moley

ps next time i'll use arrays
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top