Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    multiple checkboxes with server side?.

    I have a form with three checkboxes and multiple items shd be selected BUT

    <form>
    What type of pets do you have?
    cat <input type="checkbox" name="pet" value="cat">
    dog <input type="checkbox" name="pet" value="dog">
    rabbit <input type="checkbox" name="pet" value="rabbit" checked>
    </form>
    IF I SELECT MULTIPLE ITEMS AND CLICK ON SUBMIT BUTTON.
    THE QUERY submit_query WILL HAVE TAKEN ONLY ONE VALUE.

    E.G:
    CLICKED ON DOG AND RABBIT.
    QUERY TAKES INPUT AS "DOG" NOT AS "DOG RABBIT" .why????

    In ACTION=SrvGetParams

    I AM USING SERVLETS FOR SERVER SIDE PROCESSING AND MY STATEMENTS are

    String AnimalType = request.getParameter("AnimalType")

    Then construct my SQL query as:

    query ="scratch..submit_query "
    +" ' " +AnimalType+ " ' "........
    ......... other form params...!...


    __________________
    vijay...life is awesome!
    vijay...life is awesome!

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    turn the pets input into an array ...


    cat <input type="checkbox" name="pet[]" value="cat">
    dog <input type="checkbox" name="pet[]" value="dog">
    rabbit <input type="checkbox" name="pet[]" value="rabbit" checked>

    now check your pets variable , it will be an array containing the values you selected.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •