Problem in Response.write statement to retrieve a field in a check

J

Jack

Hi,
Here is my problem:

I am logging in to a page, where the page retrieves a record from a database.
The text boxes are used in the display formto let the users update the
fields,
if they desire to.

The colorpreference and foodpreference fields are text fields
while the FinalUpdate field is a yes/no field in Access Database.

While retieving the values, the FinalUpdate field value is not showing up as
it should. e.g.
if for the record the database has a checked field for FinalUpdate(i.e. yes)
then the
chkFinalUpdate checkbox in the form should be checked. Instead it shows
unchecked. I
believe the code to retrive the value of the final update field is not
correct.

Any help is appreciated here for problem resolution. Regards

RELEVANT CODE:

<%

'Declare variables to store field values

Dim l_ColorPreference
Dim l_FoodPreference
Dim l_FinalUpdate

'Get all the fields from the database in the above variable


l_ColorPreference = RS.Fields("ColorPreference")
l_FoodPreference = RS.Fields("FoodPreference")
l_FinalUpdate = Rs.Fields("FinalUpdate")
%>

<!--In the HTML part display the values with proper formatting__>

<td>Color Preference</td>
<td><input TYPE="text" NAME="txtColorPref" SIZE="15" value =
"<%Response.Write l_ColorPreference%>"></td>

<td>Food Preference</td>
<td><input TYPE="text" NAME="txtFoodPref" SIZE="15"value =
"<%Response.Write l_FoodPreference%>"></td>
</tr>

<tr>
<td>FinalUpdate</td>
<td><input TYPE="checkbox" NAME="chkFinalUpdate" VALUE= "<%Response.Write
CInt(l_FinalUpdate)%>"></td>
</tr>
 
R

Ray Costanzo [MVP]

chkFinalUpdate should be checked, what, if l_FinalUpdate is greater than 0
or something along those lines? If so, you have to put in logic to check to
see if the value is greater than zero, and if it is, include
checked[="checked"] in your HTML.


<input TYPE="checkbox" NAME="chkFinalUpdate"
VALUE="<%=CInt(l_FinalUpdate)%>"<% If CInt(l_FinalUpdate) > 0 Then
Response.Write " checked"%>>

Ray at work
 
J

Jack

Thanks a lot for the help, Ray. I used the following code as per your advise
<td><input TYPE="checkbox" NAME="chkFinalUpdate" VALUE=
"<%=CInt(l_FinalUpdate)%>"<%If CInt(l_FinalUpdate) > 0 Then Response.Write
"checked"%>></td>

However, when the form is displayed, the form is still not displaying the
check box as checked. Earlier, I tried to see what value the variable
i_finalupdate is fetching. It is fetching a value of 1, as it should. Any
idea, why this code is not displayin the check on the check box field? Thanks
again.

Ray Costanzo said:
chkFinalUpdate should be checked, what, if l_FinalUpdate is greater than 0
or something along those lines? If so, you have to put in logic to check to
see if the value is greater than zero, and if it is, include
checked[="checked"] in your HTML.


<input TYPE="checkbox" NAME="chkFinalUpdate"
VALUE="<%=CInt(l_FinalUpdate)%>"<% If CInt(l_FinalUpdate) > 0 Then
Response.Write " checked"%>>

Ray at work


Jack said:
Hi,
Here is my problem:

I am logging in to a page, where the page retrieves a record from a database.
The text boxes are used in the display formto let the users update the
fields,
if they desire to.

The colorpreference and foodpreference fields are text fields
while the FinalUpdate field is a yes/no field in Access Database.

While retieving the values, the FinalUpdate field value is not showing up as
it should. e.g.
if for the record the database has a checked field for FinalUpdate(i.e. yes)
then the
chkFinalUpdate checkbox in the form should be checked. Instead it shows
unchecked. I
believe the code to retrive the value of the final update field is not
correct.

Any help is appreciated here for problem resolution. Regards

RELEVANT CODE:

<%

'Declare variables to store field values

Dim l_ColorPreference
Dim l_FoodPreference
Dim l_FinalUpdate

'Get all the fields from the database in the above variable


l_ColorPreference = RS.Fields("ColorPreference")
l_FoodPreference = RS.Fields("FoodPreference")
l_FinalUpdate = Rs.Fields("FinalUpdate")
%>

<!--In the HTML part display the values with proper formatting__>

<td>Color Preference</td>
<td><input TYPE="text" NAME="txtColorPref" SIZE="15" value =
"<%Response.Write l_ColorPreference%>"></td>

<td>Food Preference</td>
<td><input TYPE="text" NAME="txtFoodPref" SIZE="15"value =
"<%Response.Write l_FoodPreference%>"></td>
</tr>

<tr>
<td>FinalUpdate</td>
<td><input TYPE="checkbox" NAME="chkFinalUpdate" VALUE= "<%Response.Write
CInt(l_FinalUpdate)%>"></td>
</tr>
 
R

Ray Costanzo [MVP]

Did you include a space in " checked" as I did in my code? What does a
View-Source reveal?

Ray at work

Jack said:
Thanks a lot for the help, Ray. I used the following code as per your advise
<td><input TYPE="checkbox" NAME="chkFinalUpdate" VALUE=
"<%=CInt(l_FinalUpdate)%>"<%If CInt(l_FinalUpdate) > 0 Then Response.Write
"checked"%>></td>

However, when the form is displayed, the form is still not displaying the
check box as checked. Earlier, I tried to see what value the variable
i_finalupdate is fetching. It is fetching a value of 1, as it should. Any
idea, why this code is not displayin the check on the check box field? Thanks
again.

Ray Costanzo said:
chkFinalUpdate should be checked, what, if l_FinalUpdate is greater than 0
or something along those lines? If so, you have to put in logic to check to
see if the value is greater than zero, and if it is, include
checked[="checked"] in your HTML.


<input TYPE="checkbox" NAME="chkFinalUpdate"
VALUE="<%=CInt(l_FinalUpdate)%>"<% If CInt(l_FinalUpdate) > 0 Then
Response.Write " checked"%>>

Ray at work


Jack said:
Hi,
Here is my problem:

I am logging in to a page, where the page retrieves a record from a database.
The text boxes are used in the display formto let the users update the
fields,
if they desire to.

The colorpreference and foodpreference fields are text fields
while the FinalUpdate field is a yes/no field in Access Database.

While retieving the values, the FinalUpdate field value is not showing
up
as
it should. e.g.
if for the record the database has a checked field for
FinalUpdate(i.e.
yes)
then the
chkFinalUpdate checkbox in the form should be checked. Instead it shows
unchecked. I
believe the code to retrive the value of the final update field is not
correct.

Any help is appreciated here for problem resolution. Regards

RELEVANT CODE:

<%

'Declare variables to store field values

Dim l_ColorPreference
Dim l_FoodPreference
Dim l_FinalUpdate

'Get all the fields from the database in the above variable


l_ColorPreference = RS.Fields("ColorPreference")
l_FoodPreference = RS.Fields("FoodPreference")
l_FinalUpdate = Rs.Fields("FinalUpdate")
%>

<!--In the HTML part display the values with proper formatting__>

<td>Color Preference</td>
<td><input TYPE="text" NAME="txtColorPref" SIZE="15" value =
"<%Response.Write l_ColorPreference%>"></td>

<td>Food Preference</td>
<td><input TYPE="text" NAME="txtFoodPref" SIZE="15"value =
"<%Response.Write l_FoodPreference%>"></td>
</tr>

<tr>
<td>FinalUpdate</td>
<td><input TYPE="checkbox" NAME="chkFinalUpdate" VALUE= "<%Response.Write
CInt(l_FinalUpdate)%>"></td>
</tr>
 
J

Jack

The following is the view source result:

<tr>
<td><input TYPE="SUBMIT" NAME="btnSubmit" VALUE="SUBMIT"></td>
</tr>
This shows no value in the above.
Now, when I did a response.write l_finalupdate where this is the variable to
which
the value of Rs.Fields("FinalUpdate") is assigned, it gives a True results
instead of 1.
Any further thoughts. Thanks.

Ray Costanzo said:
Did you include a space in " checked" as I did in my code? What does a
View-Source reveal?

Ray at work

Jack said:
Thanks a lot for the help, Ray. I used the following code as per your advise
<td><input TYPE="checkbox" NAME="chkFinalUpdate" VALUE=
"<%=CInt(l_FinalUpdate)%>"<%If CInt(l_FinalUpdate) > 0 Then Response.Write
"checked"%>></td>

However, when the form is displayed, the form is still not displaying the
check box as checked. Earlier, I tried to see what value the variable
i_finalupdate is fetching. It is fetching a value of 1, as it should. Any
idea, why this code is not displayin the check on the check box field? Thanks
again.

Ray Costanzo said:
chkFinalUpdate should be checked, what, if l_FinalUpdate is greater than 0
or something along those lines? If so, you have to put in logic to check to
see if the value is greater than zero, and if it is, include
checked[="checked"] in your HTML.


<input TYPE="checkbox" NAME="chkFinalUpdate"
VALUE="<%=CInt(l_FinalUpdate)%>"<% If CInt(l_FinalUpdate) > 0 Then
Response.Write " checked"%>>

Ray at work


Hi,
Here is my problem:

I am logging in to a page, where the page retrieves a record from a
database.
The text boxes are used in the display formto let the users update the
fields,
if they desire to.

The colorpreference and foodpreference fields are text fields
while the FinalUpdate field is a yes/no field in Access Database.

While retieving the values, the FinalUpdate field value is not showing up
as
it should. e.g.
if for the record the database has a checked field for FinalUpdate(i.e.
yes)
then the
chkFinalUpdate checkbox in the form should be checked. Instead it shows
unchecked. I
believe the code to retrive the value of the final update field is not
correct.

Any help is appreciated here for problem resolution. Regards

RELEVANT CODE:

<%

'Declare variables to store field values

Dim l_ColorPreference
Dim l_FoodPreference
Dim l_FinalUpdate

'Get all the fields from the database in the above variable


l_ColorPreference = RS.Fields("ColorPreference")
l_FoodPreference = RS.Fields("FoodPreference")
l_FinalUpdate = Rs.Fields("FinalUpdate")
%>

<!--In the HTML part display the values with proper formatting__>

<td>Color Preference</td>
<td><input TYPE="text" NAME="txtColorPref" SIZE="15" value =
"<%Response.Write l_ColorPreference%>"></td>

<td>Food Preference</td>
<td><input TYPE="text" NAME="txtFoodPref" SIZE="15"value =
"<%Response.Write l_FoodPreference%>"></td>
</tr>

<tr>
<td>FinalUpdate</td>
<td><input TYPE="checkbox" NAME="chkFinalUpdate" VALUE= "<%Response.Write
CInt(l_FinalUpdate)%>"></td>
</tr>
 
R

Ray Costanzo [MVP]

You posted the view-source snippet for your submit button, not the checkbox
in question...

As far as the true/false, that's fine, but you were CInt'ing the value
before.

Ray at work
 
J

Jack

Sorry for the screw up. The view source shows as follows:
<tr>
<td>FinalUpdate</td>
<td><input TYPE="checkbox" NAME="chkFinalUpdate" VALUE= "-1"></td>
</tr>
You are right that I did CInt previously. I must have chagned code and it
got dropped. When I put CInt(l_finalupdate) and wrote a response.write, then
it gave me a -1. I checked the value in the back-end and it shows checked in
the field.
Thanks.
 
R

Ray Costanzo [MVP]

Well, obviously -1 is not greater than 0... CBool it.

<input TYPE="checkbox" NAME="chkFinalUpdate"
VALUE="<%=CInt(l_FinalUpdate)%>"<% If CBool(l_FinalUpdate) Then
Response.Write " checked"%>>

Ray at work
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top