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 6 of 6

Thread: Help In Asp.

  1. #1
    New Coder
    Join Date
    Apr 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Help In Asp.

    Hi!
    i am trying to fetch the values from an html page and then inserting them into a database using asp.

    i want to know how to fetch the value from a check box and insert in the database..


    there are check boxes named:

    chk_sunday value:Sunday
    chk_mon value :Monday
    chk_tue value : Tuesday
    chk_wed value :Wednesday
    chk_thur value : Thursday
    chk_fri value : Friday
    chk_sat value : Saturday

    Code:
    <input type="checkbox" name="chk_sun" value="Sunday">
    <input type="checkbox" name="chk_mon" value="Monday">
    <input type="checkbox" name="chk_tue" value="Tuesday">
    <input type="checkbox" name="chk_wed" value="Wednesday">
    <input type="checkbox" name="chk_thur" value="Thursday">
    <input type="checkbox" name="chk_fri" value="Friday">
    <input type="checkbox" name="chk_sat" value="Saturday">
    Please help me

  • #2
    New Coder
    Join Date
    Apr 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i wish to insert only those values for which the check box has been checked

  • #3
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    You get a value from a posted form element by using request.form(element_name)

    With checkboxes, if the box isn't checked, nothing gets sent through.

    So you'd do:

    if request.form("chk_sun") = "Sunday" then
    ' do database stuff
    end if

    If you're not familiar with this then I'd suggest you start with some simple ASP tutorials - http://www.w3schools.com/asp - because if you don't know how to get values out of a form, you're going to find connecting to a database and running SQL statements against it a whole world of complicated.

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Also there are different methods to get the requested variables into the query.

    It depends on how your database is setup.

  • #5
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    Yea if you dont supply a "value" in the form it will be "on" or "off" and if you give them all the same name it will be a comma separated list of "on"s. All these methods can be very useful in different situations.

  • #6
    New Coder
    Join Date
    Apr 2007
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot guys!
    now the form is working...


  •  

    Posting Permissions

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