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 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Jul 2006
    Location
    Belvidere, IL
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code for button to refresh page after inserting data in sql db

    I am creating an application where when the user has answered all questions and hit the 'add new item' button, the data is inserted into the database and the page will refresh so the user can fill it in again for the next item on the quote. I need this to happen continuously until they hit the 'finish' button which will then insert the data and also send the email. I have everything working except for the 'add new item' button. Can anyone help me understand how to have this button insert the data into the database and refresh for the next entry?

    Here's my insert statement...

    Code:
    strSQL = "INSERT into cyl.dbo.Quote_Requirements (" _
               & "Cust_ID, " _
               & "qty_per_ord, " _
               & "qty_per_yr, " _
               & "t_price, " _    
               & "quoted, " _
               & "q_num, " _
               & "built, " _
               & "Serial_num, " _
               & "model_num,  " _
               & "spec_mods, " _
               & "design_built, " _
               & "match_design, " _
               & "mfg_name, " _
               & "service, " _
               & "series, " _
               & "bore, " _
               & "rod_dia, " _
               & "wk_stroke, " _
               & "stroke_tol_plus, " _
               & "stroke_tol_neg, " _
               & "lholding, " _
               & "hyd_shock, " _
               & "low_friction, " _
               & "press_rise, " _          
               & "dbl_rod, " _
               & "press_rod_end, " _
               & "press_cap_end, " _
               & "s_extend, " _
               & "s_retract, " _
               & "rod_end_type, " _
               & "rod_end_size, " _
               & "rod_end_loc, " _
               & "cap_end_type, " _
               & "cap_end_size, " _
               & "cap_end_loc, " _
               & "bolt_on, " _
                  & "bom_adder, " _
               & "bom_spec, " _
               & "integral, " _
               & "icm_adder, " _
               & "icm_spec, " _
               & "fluid_type, " _
               & "oper_temp, " _
               & "pseal_type, " _
               & "rseal_type, " _
               & "mtg_styles, " _
               & "mtg_mode, " _
               & "load_guide, " _
               & "cush_cap, " _
               & "cush_head, " _
               & "rod_speed, " _
               & "load_push, " _
               & "load_pull, " _
               & "cycle_rate, " _
               & "cycle_duty, " _
               & "side_load, " _
               & "rod_position, " _
               & "environment, " _
               & "sgl_act, " _
               & "pre_load, " _
               & "press_avail, " _
               & "final_load, " _
               & "spec_matl, " _
               & "spec_paint, " _
               & "draw_num, " _
               & "rev_num, " _
               & "elec_req, " _
               & "transducer,  " _
               & "trans_comments, " _
               & "thaz_env, " _
               & "tnema_enc, " _
               & "TnemaRate, " _
               & "safe_trans, " _
               & "AnaOut, " _
               & "DigOut, " _
               & "interrogation, " _
               & "recirc, " _
               & "format, " _
               & "resolution, " _
               & "performance, " _
               & "opts, " _
               & "protocol, " _
               & "baud_rate, " _
               & "baud_res, " _
               & "switches, " _
               & "switch_comments, " _
               & "shaz_env, " _
               & "snema_enc, " _
               & "SnemaRate, " _
               & "safe_switch, " _
               & "ACSwitchLoc, " _
               & "DCSwitchLoc, " _
               & "connector, " _
               & "electron) " _
               & "values (" & SESSION("CustId") & ", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
    And here's the code for the button...

    Code:
     <div align="center">
    <input type="button" onClick="modalWin2()"name="button" value="Attach Documents"><br><br>
    <input type="submit" name="button" value="Add Another Item?" ?onClick="document.reload."?> This is where I have my question...what should I put in the onClick function????
    
    
    <input type="submit" name="button" value="Finish" onClick="return validateRadioButton();">
    <input type="reset" name="Reset" value="Clear">
    </div>
    </FORM>
    Any help would be greatly appreciated.

  • #2
    Registered User
    Join Date
    Jan 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can run this doing some simple ASP If statements if you want.

    If Request.Form("button") = "Add Another Item?" Then
    'INSERT INTO DATABASE
    'DISPLAY FORM
    ElseIf
    'INSERT INTO DATABASE
    'SEND EMAIL
    'DISPLAY WHATEVE RYOU WANT
    End If

  • #3
    New to the CF scene
    Join Date
    Jul 2006
    Location
    Belvidere, IL
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you. I will try that and will let you know how it turns out.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,037
    Thanks
    0
    Thanked 250 Times in 246 Posts
    And to display the form, just redirect to the form after the data has been inserted to the database.
    Code:
    Response.Redirect "addnewform.asp"


  •  

    Posting Permissions

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