Check box and asp vbscript

This should be easy, but I'm not getting it right.  

pulling data from a db, I have fields that are check boxes on the form but logged as 1 or 0 (checked or unchecked).  Can somebody give me a template if statement for reporting out those fields on query as check boxes, checked and unchecked?
rhkennerlyAsked:
Who is Participating?
 
Ryan ChongCommented:
try:

<input name=
                              "<%=(htmlentities(tasker.Fields.Item("tasker_active").Value))%>"
                              type = "checkbox" id="<%=(htmlentities(tasker.Fields.Item("tasker_active").Value))%>"
                              value = "1"
                              <%=chkopt(trim("" & htmlentities(tasker.Fields.Item("tasker_active").Value))), "1", "checked")%>  />
0
 
Ryan ChongCommented:
what's your server side language, database you're using? do you have a developed page, so that we can amend it for you, so that we not need to create a sample for you from scratch, cheers
0
 
rhkennerlyAuthor Commented:
Sorry, it is in the title--asp vbscript--and I can't share the page there is propriatary info on it.  
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Ryan ChongCommented:
oops, sorry, basically you'll need to check the value of a field, if the value returns "1", you'll then write a "Checked" on your page, like:

<%
      function chkopt(v1, v2, checked)
            if v1 = v2 then chkopt = checked
      end function
%>

...
  <input name="myvalue" type="checkbox" id="myvalue" value="1" <%=chkopt(trim("" & rs("myfield")),"1"," checked")%>>
...

get the idea? regards
0
 
rhkennerlyAuthor Commented:
I really appreciate the help.  I am almost there, but it hangs at the end and I can't pick it out.


<input name=
                                    "<%=(htmlentities(tasker.Fields.Item("tasker_active").Value))%>"
                                    type = "checkbox" id="<%=(htmlentities(tasker.Fields.Item("tasker_active").Value))%>"
                                    value = "1"
                                    <%=chkopt(trim(""&rs("<%=(htmlentities(tasker.Fields.Item("tasker_active").Value))%>")), "1", "checked")%>  />

Error Type:
Microsoft VBScript compilation (0x800A03EE)
Expected ')'
/spec_man/tasker/admin_total.asp, line 655, column 71
Response.Write(chkopt(trim(""&rs("<%=(htmlentities(tasker.Fields.Item("tasker_active").Value)))
----------------------------------------------------------------------^


Browser Type:
0
 
rhkennerlyAuthor Commented:
That got her done (although you gave me one too many ")").  Thanks for taking the time.  You were a great help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.