#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    9
    Rep Power
    0

    Multiple Check box


    Hi, there
    I have a search page with multiple fields...
    One of them is Category field.
    I have 2 check box(with different names) with 2 values . 1)ExternalTask 2)InternalTask.


    I don't know what sql code to write if user has checked
    more than one choice.
    Actually i want to show only ExternalTask or InternalTask only if user has checked ExternalTask or InternalTask check box. Or both if user checked both check boxes.

    For example the code below,if i write the "and" between the two
    "Category" it works only if i choose one check box, if i choose
    both check boxes it doesn't work(Display No Records...)
    But if i replace the "and" between the two "Category" in the code with "OR" it works only if i choose both check boxes.
    *The rest of code it works properly

    strsql="select * from [QryTask1] where NotesID like '" & replace(request("txtid"),"'","''") & "' and Priority like '%" & replace(request("txtpriority"),"'","''") & "%' and Description like '%" & replace(request("txtDesc"),"'","''") & "%' and Category
    like '%" & request("txtCategory") & "%' and Category like
    '%" & request("txtCategory1") & "%'

    Regards
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,428
    Rep Power
    4539
    and (txtbox1 OR txtbox2) might work (use actual names for txtboxN)
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    9
    Rep Power
    0
    Originally Posted by Doug G
    and (txtbox1 OR txtbox2) might work (use actual names for txtboxN)
    Thanks for your response..
    I have tried this but it doesn't works
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2010
    Posts
    15
    Rep Power
    0
    looks like a logic problem in your SQL.

    You are trying to test for two parameters 'internal' and 'external' but are only looking at one field 'Category' .

    problem could also be a flaw in your database design. it's not clear how you distinguish between internal and external in your database structure.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    9
    Rep Power
    0
    oK i HAVE WRITE THIS AND IT WORKS

    Category like request("txtCategory") or Category like
    request("txtCategory1)

    Thanks
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    1
    Rep Power
    0
    assign a value to your checkboxes when you design the search form. Then when the search was submitted, have a condition that evaluates the value of the checkboxes. Then your sql statement would differ depending on the result of the condition.




    Rey G. Calanta-ol
    ASP Programmer

IMN logo majestic logo threadwatch logo seochat tools logo