Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 271
  • Last Modified:

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?
0
rhkennerly
Asked:
rhkennerly
  • 3
  • 3
1 Solution
 
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
 
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
Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

 
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
 
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
 
rhkennerlyAuthor Commented:
That got her done (although you gave me one too many ")").  Thanks for taking the time.  You were a great help.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now