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

Discussion in 'ASP General' started by Jack, Dec 15, 2004.

  1. Jack

    Jack Guest

    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>
     
    Jack, Dec 15, 2004
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:...
    > 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>
     
    Ray Costanzo [MVP], Dec 15, 2004
    #2
    1. Advertising

  3. Jack

    Jack Guest

    Re: Problem in Response.write statement to retrieve a field in a c

    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 [MVP]" wrote:

    > 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" <> wrote in message
    > news:...
    > > 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>

    >
    >
    >
     
    Jack, Dec 15, 2004
    #3
  4. Re: Problem in Response.write statement to retrieve a field in a c

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

    Ray at work

    "Jack" <> wrote in message
    news:...
    > 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 [MVP]" wrote:
    >
    > > 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" <> wrote in message
    > > news:...
    > > > 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>

    > >
    > >
    > >
     
    Ray Costanzo [MVP], Dec 15, 2004
    #4
  5. Jack

    Jack Guest

    Re: Problem in Response.write statement to retrieve a field in a c

    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 [MVP]" wrote:

    > Did you include a space in " checked" as I did in my code? What does a
    > View-Source reveal?
    >
    > Ray at work
    >
    > "Jack" <> wrote in message
    > news:...
    > > 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 [MVP]" wrote:
    > >
    > > > 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" <> wrote in message
    > > > news:...
    > > > > 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>
    > > >
    > > >
    > > >

    >
    >
    >
     
    Jack, Dec 15, 2004
    #5
  6. Re: Problem in Response.write statement to retrieve a field in a c

    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



    "Jack" <> wrote in message
    news:...
    > 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 [MVP]" wrote:
    >
    > > Did you include a space in " checked" as I did in my code? What does a
    > > View-Source reveal?
    > >
    > > Ray at work
     
    Ray Costanzo [MVP], Dec 15, 2004
    #6
  7. Jack

    Jack Guest

    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.

    "Jack" wrote:

    > 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>
     
    Jack, Dec 15, 2004
    #7
  8. 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

    "Jack" <> wrote in message
    news:...
    > 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.
    >
    > "Jack" wrote:
    >
    > > 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 t
     
    Ray Costanzo [MVP], Dec 15, 2004
    #8
  9. Jack

    Jack Guest

    Re: Problem in Response.write statement to retrieve a field in a c

    Ray, it works now. Many thanks for this. Regards.

    "Ray Costanzo [MVP]" wrote:

    > 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
    >
    > "Jack" <> wrote in message
    > news:...
    > > 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.
    > >
    > > "Jack" wrote:
    > >
    > > > 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 t

    >
    >
    >
     
    Jack, Dec 15, 2004
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles A. Lackman
    Replies:
    2
    Views:
    8,072
    Charles A. Lackman
    Jan 11, 2006
  2. Rick
    Replies:
    3
    Views:
    8,511
    Alexey Smirnov
    Apr 13, 2010
  3. Sal
    Replies:
    1
    Views:
    916
  4. Jack
    Replies:
    2
    Views:
    256
  5. Jack
    Replies:
    2
    Views:
    105
Loading...

Share This Page