0

Hello everyone,
I have a problem with an ASP porgram and I will be very glad for your assist.
In the database, I have table (BOK) and column (STATUS), this column is a databite with only 1 and 0 values.

I have two checkbox in the HTML code.

This work very well to put from 0 to 1 in the database
Tillgänglig <input type="checkbox" name="synlig" value ="on">
<%
If synlig = "on" Then
rsBok("status") = True
End If %>


But in other checkbox, I try to put the same bok från 1 to 0 but don´t work

Otillgänglig <input type="checkbox" name="osynlig" value ="on">
<%
If osynlig = "on" Then
rsBok("status") = False
End If %>

Please can you help me to solve this problem

Kind regards,
Eric

2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by arden_k
0

Hi Eric,
Why are you using 2 check boxes for one field? 1 will work and it is less complicated.

<%
If synlig = "on" Then
rsBok("status") = True
else
rsBok("status") = False
End If 
%>

You are setting both check boxed to "value=on", the field can not be true and false at the same time.

If you have to have 2 check boxes set one to "value = off". Also add code to check both boxes to make sure one is on and the other is off.

hth
Arden

0

Hi Arden,
Thank u very much for your answer.
The reason that I´m using two checkbox is becuause one box is for the book från False to True and that work very well, and the other box is for the books from True to False, that doesn´t work at all.

I had already tried with value="off", like you mention it but nothing happend, the value in the database is still True:
Otillgänglig <input type="checkbox" name="osynlig" value="off">
<%
If synlig = "off" Then
rsBok("status") = False
End If
%>

I wondering if it can be something with the Stored Procedure in the SQL database. I had already the variable declared:
CREATE PROCEDURE sp_ChangeBok (@Status as bit ) AS
set @Status = rtrim(ltrim(@Status))

if len(@Status) < 1
begin
select @Status = 0
end
else
begin
select @Status = 1
end

update BOK
set STATUS = @Status

Thank you in advance,
Eric


Hi Eric,
Why are you using 2 check boxes for one field? 1 will work and it is less complicated.

<%
If synlig = "on" Then
rsBok("status") = True
else
rsBok("status") = False
End If 
%>

You are setting both check boxed to "value=on", the field can not be true and false at the same time.

If you have to have 2 check boxes set one to "value = off". Also add code to check both boxes to make sure one is on and the other is off.

hth
Arden

0

Hi Eric,
The logic isn't quite clear, please correct me if I'm wrong. If true, box `1 is checked, box 2 is not. If false box 1 is not checked, box 2 is checked. If this is the case you should use a "radio button" control group. There is a nice example at the bottom of this page, "was this helpful": http://msdn.microsoft.com/en-us/library/xke2zw4x(v=vs.71).aspx

Using a stored procedure might work but I think you are over complicating the task, I like to keep things as simple as possible.

Another possible solution is to use a True/False "combo box" aka "drop down list".

hth,
Arden

0

Hi Arden_K,
Thank u very much for your support,
In the first checkbox (titel: Tillgänglig) change from 0 (false) to 1 (true) in the status tabell and that works fine but when I try to do in the other checkbox (titel: Otillgänglig) from 1 (true) to o (false) in the status column, doesn´t work at all.

So I need to have one checkbox to have that status of the book true (that works without any problem) and onether checkbox to have the status of the book false (not working).

I saw the link about radiobuttons, but this is in .NET and I´m working only with ASP, how will be the code to ASP?

KR,
Eric


Hi Eric,
The logic isn't quite clear, please correct me if I'm wrong. If true, box `1 is checked, box 2 is not. If false box 1 is not checked, box 2 is checked. If this is the case you should use a "radio button" control group. There is a nice example at the bottom of this page, "was this helpful": http://msdn.microsoft.com/en-us/library/xke2zw4x(v=vs.71).aspx

Using a stored procedure might work but I think you are over complicating the task, I like to keep things as simple as possible.

Another possible solution is to use a True/False "combo box" aka "drop down list".

hth,
Arden

0

Hi Eric,
I mentioned the .NET link as an example to get an idea if that is what you were looking for. This link has an example of radio buttons: http://forums.devx.com/archive/index.php/t-97840.html


I think the problem with the check boxes is you need a "on update event" to get it to work. The problem is, I don'r think ASP Classic has this event.

I think the best option/work around is the combo box because ASP Classic is limited in functionality

Best,
AK

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.