1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Multi checkbox insert

Discussion in 'C#' started by devmonk, Sep 28, 2006.

  1. #1
    I have a form that is passing a number to check box values with the same name (productID) but different values (numerical values). It is also passing a warehouseID as a hidden field.
    SEMrush
    I need to dump these values into an access table called wtbProductWarehouses with fields titled ProductID and WarehouseID. What is the code that I need to write to have it loop through all of the productID values and individually add each one to the db while also adding the warehouseID with it.

    Thanks so much!

    Jason
     
    devmonk, Sep 28, 2006 IP
    SEMrush
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,607
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    i would give each checkbox a Name in your html (created via script) like warehouseproduct_ProductID_WarehouseID

    <input name="warehouseproduct_3_12" />

    then iterate over all the posted form elements
    if the form element's first x chars equals "warehouseproduct_" then you know you are dealing with a checkbox. then do a Split of the form elements Name - and if the form elements value is checked. splitVar(1) = your productid and splitVar(2) = your warehouseID.

    Hope this helps - theirs plenty of source on the web for this :)
     
    ccoonen, Sep 28, 2006 IP