...

View Full Version : Code for button to refresh page after inserting data in sql db



wacara
04-27-2007, 03:25 AM
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...


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...


<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.

Archangel
04-27-2007, 04:23 PM
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

wacara
04-30-2007, 03:30 PM
Thank you. I will try that and will let you know how it turns out.

glenngv
05-01-2007, 03:51 PM
And to display the form, just redirect to the form after the data has been inserted to the database.

Response.Redirect "addnewform.asp"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum