473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

redirect delay on form submit not working

120 100+
hi guys

I am pulling in prices/dates from a sql server database/table on to a webpage using sql/asp/html/css.

these prices/dates are then editable via a simple sql update statement on a css/div popup box. once edited the prices are updated on the sql database/table with no problems.

problem is when new prices are entered on the css/div popup box you have to manually refresh the page to pull in the new prices from the database.

what I would like is to be able to enter the prices and then as soon as the submit button is pressed the webpage refresh's displaying the latest prices.

I've tried all sorts of asp/javascript redirects but am really stuck.. below is my code

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Prices TEST</title>
  6.  
  7. <SCRIPT language="JavaScript"><!--
  8. function FormRedirect(){
  9. setTimeout('this.document.location.href = "http://www.canadianaffair.com/prices-database/updated.asp"',5000);}
  10. //--></SCRIPT>
  11.  
  12. </head>
  13. <body>
  14. <%
  15. DIM objConn
  16. Set objConn = Server.CreateObject("ADODB.Connection")
  17. objConn.ConnectionString = REMOVED
  18. objConn.Open
  19.  
  20. DIM mySQL
  21. mySQL = "SELECT * FROM UK_Specials"
  22.  
  23. DIM objRS
  24. Set objRS = Server.CreateObject("ADODB.Recordset")
  25. objRS.Open mySQL, objConn
  26. %>
  27.  
  28. <a name="LGWYYZ"></a>
  29. <table align="center" cellpadding="0" cellspacing="0">
  30.   <tr>
  31.     <td style="vertical-align:top; padding:0px 15px 0 0"><fieldset class="fieldsetspecialpricebox">
  32.       <legend><span class="specialtitlesmall">GATWICK to TORONTO</span></legend>
  33.       <table align="center" cellpadding="0" cellspacing="0" class="specialpricetable">
  34.         <tr>
  35.           <td class="priceheadertd">Price</td>
  36.           <td class="dateheadertd">Outbound Date/s</td>
  37.         </tr>
  38.         <tr>
  39.           <td colspan="2" height="10">&nbsp;</td>
  40.         </tr>
  41.         <tr>
  42.           <td class="pricetd">&pound; <% Response.Write objRS("Price_Band_1") %></td>
  43.           <td class="datetd"><strong>March</strong> <% Response.Write objRS("Date_Band_1") %></td>
  44.         </tr>
  45.         <tr>
  46.           <td class="pricetd">&pound; <% Response.Write objRS("Price_Band_2") %></td>
  47.           <td class="datetd"><strong>April</strong> <% Response.Write objRS("Date_Band_2") %></td>
  48.         </tr>
  49.         <tr>
  50.           <td class="pricetd">&pound; <% Response.Write objRS("Price_Band_3") %></td>
  51.           <td class="datetd"><strong>May</strong> <% Response.Write objRS("Date_Band_3") %> </td>
  52.         </tr>
  53.         <tr>
  54.           <td class="pricetd">&pound; <% Response.Write objRS("Price_Band_3") %></td>
  55.           <td class="datetd"><strong>June</strong> <% Response.Write objRS("Date_Band_4") %> </td>
  56.         </tr>
  57.         <tr>
  58.           <td><a onmouseover='this.style.cursor="pointer" ' onfocus='this.blur();' onclick="document.getElementById('PopUp').style.display = 'block' " ><span style="text-decoration: underline;">EDIT PRICES</span></a></td>
  59.           <td style="padding:0px 0 0 100px"><a class="button" href="#BackToTop" onclick="change_booking('LGW','YYZ')" >BOOK NOW !</a></td>
  60.         </tr>
  61.       </table>
  62.       </fieldset>
  63.  
  64. <%
  65. ' Don't forget to close your connection after you display your data.
  66. objRS.Close
  67. Set objRS = Nothing
  68. objConn.Close
  69. Set objConn = Nothing
  70. %>
  71.  
  72. </td>
  73.   </tr>
  74. </table>
  75.  
  76. <div id='PopUp' style='display: none; position: absolute; left: 450px; top: 50px; border: solid black 1px; padding: 10px; background-color: rgb(255,255,225); text-align: justify; font-size: 12px; width: 210px;'>
  77. <form name="UKSpecialsUpdate" method="post" action="default.asp" />
  78.   <table align="center" width="100%" cellpadding="0" cellspacing="0" style="margin:0">
  79.     <tr>
  80.       <td width="30%">Price</td>
  81.       <td>Outbound Date/s</td>
  82.     </tr>
  83.     <tr>
  84.       <td><input name="ID1PriceBand1" type="text" id="ID1PriceBand1" size="4" maxlength="4" value=""></td>
  85.       <td><input name="ID1DateBand1" type="text" id="ID1DateBand1" size="20" maxlength="100" value=""></td>
  86.     </tr>
  87.     <tr>
  88.       <td><input name="ID1PriceBand2" type="text" id="ID1PriceBand2" size="4" maxlength="4" value=""></td>
  89.       <td><input name="ID1DateBand2" type="text" id="ID1DateBand2" size="20" maxlength="100" value=""></td>
  90.     </tr>
  91.     <tr>
  92.       <td><input name="ID1PriceBand3" type="text" id="ID1PriceBand3" size="4" maxlength="4" value=""></td>
  93.       <td><input name="ID1DateBand3" type="text" id="ID1DateBand3" size="20" maxlength="100" value=""></td>
  94.     </tr>
  95.     <tr>
  96.       <td><input name="ID1PriceBand4" type="text" id="ID1PriceBand4" size="4" maxlength="4" value=""></td>
  97.       <td><input name="ID1DateBand4" type="text" id="ID1DateBand4" size="20" maxlength="100" value=""></td>
  98.     </tr>
  99.     <tr>
  100.       <td valign="middle"><div style='text-align: left;'><a onmouseover='this.style.cursor="pointer" ' style='font-size: 12px;' onfocus='this.blur();' onclick="document.getElementById('PopUp').style.display = 'none' " ><span style="text-decoration: underline;">Close</span></a></div>
  101.     </div>
  102.  
  103.     </td>
  104.  
  105.     <td style="padding:20px 0 0 0" align="right"><input name="Submit" type="submit" value="Update!!" onclick="FormRedirect()"/>
  106.  
  107.         <%
  108. 'declare your variables
  109. Dim connection, sSQL, sConnString
  110. Price_Band_1=Request.Form("ID1PriceBand1")
  111. Date_Band_1=Request.Form("ID1DateBand1")
  112. Price_Band_2=Request.Form("ID1PriceBand2")
  113. Date_Band_2=Request.Form("ID1DateBand2")
  114. Price_Band_3=Request.Form("ID1PriceBand3")
  115. Date_Band_3=Request.Form("ID1DateBand3")
  116. Price_Band_4=Request.Form("ID1PriceBand4")
  117. Date_Band_4=Request.Form("ID1DateBand4")
  118.  
  119. 'declare SQL statement that will query the database
  120. sSQL="UPDATE UK_Specials SET Price_Band_1='" & Price_Band_1 & "', Date_Band_1='" & Date_Band_1 & "', Price_Band_2='" & Price_Band_2 & "', Date_Band_2='" & Date_Band_2 & "', Price_Band_3='" & Price_Band_3 & "', Date_Band_3='" & Date_Band_3 & "', Price_Band_4='" & Price_Band_4 & "', Date_Band_4='" & Date_Band_4 & "'  WHERE ID='1'"
  121.  
  122. 'create an ADO connection object
  123. Set connection = Server.CreateObject("ADODB.connection")
  124.  
  125. 'define the connection string, specify database
  126. 'driver and the location of database
  127. sConnString=REMOVED
  128.  
  129. 'Open the connection to the database
  130. Connection.Open sConnString
  131.  
  132. 'Execute the SQL statement
  133. Connection.Execute sSQL
  134.  
  135. 'Now close the connection object
  136. connection.Close
  137. Set connection = Nothing
  138.  
  139. %>
  140.  
  141. </form>
  142.       </td>
  143.     </tr>
  144.   </table>
  145. </body>
  146. </html>
  147.  
any help would be appreciated

thanks in advance
Omar.
Mar 15 '10 #1

✓ answered by Soniad

Hi,

You have set the time period,only after that time your page will get redirected. Either reduce the time or directly submit your page.
For refreshing the page,Try the following statement after "Set connection = Nothing"
Expand|Select|Wrap|Line Numbers
  1. Response.AddHeader "Refresh", "1;URL=http://www.canadianaffair.com/prices-database/updated.asp"
Also check the link given below :
http://classicasp.aspfaq.com/general...e-refresh.html

Regards,

"D"

2 2890
Soniad
66
Hi,

You have set the time period,only after that time your page will get redirected. Either reduce the time or directly submit your page.
For refreshing the page,Try the following statement after "Set connection = Nothing"
Expand|Select|Wrap|Line Numbers
  1. Response.AddHeader "Refresh", "1;URL=http://www.canadianaffair.com/prices-database/updated.asp"
Also check the link given below :
http://classicasp.aspfaq.com/general...e-refresh.html

Regards,

"D"
Mar 17 '10 #2
omar999
120 100+
thanks for the response : )

this was very useful and has solved my query.
Mar 17 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Paul Oakfleet | last post by:
The script below will disable Submit button until user accept terms, and will redirect user to another page after clicking on Submit button. The script seems to work fine on my PC (Windows XP,...
13
by: deko | last post by:
I have a basic feedback form with a submit button. After the "send" button is clicked, I want the user to be redirected to a different page that says "Your message has been sent." How do I do...
8
by: Laith Zraikat | last post by:
I am trying to invoke a post request from code behind of an asp.net page using "WebClient" object, and I want the user to be redirected to the action url as well. So far Ive been able to send...
3
by: new214 | last post by:
heya all, ive got abit of a problem. Im doin a system in asp- which works on a test server- but when on moving my application to a development server- it throws the following error messages where I...
4
by: nkoier | last post by:
Hi, I've been going crazy trying to figure out what's wrong with our Asp.Net 2.0 intranet site. At the very top of our main page I provide a TextBox and a Button for submitting Google searches....
5
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
I am trying to create ASPX code which will allow me to redirect a user to another site with POST data. I figure that the best way to do this is with JavaScript to the client. Here's what I'm doing:...
5
by: ozman | last post by:
Hi, I'm having a problem with delaying a redirect of a page. I created a contact form and if the user does not fill in the fields, I'm echoing the message, but at the same time I want it coming...
2
by: sindhudixit | last post by:
Hey, I am having a user fill out a form then the fields are going to uploaded to my database. So, at this point, when the user hits the submit button I want three things to happen: 1. The...
5
by: ania.malicka85 | last post by:
Hello, I am playing with automatic redirection with PHP. As with GET is fairly simple (<meta http-equiv="refresh" content="3;url="http:// www.google.com/search?q=php"> how can I do similar...
1
by: gnawz | last post by:
Hi guys, I have a couple of php files that perform various tasks. I will use fields in my system and provide code as well I need help as follows: My database contains the fields Category...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.