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
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Prices TEST</title>
- <SCRIPT language="JavaScript"><!--
- function FormRedirect(){
- setTimeout('this.document.location.href = "http://www.canadianaffair.com/prices-database/updated.asp"',5000);}
- //--></SCRIPT>
- </head>
- <body>
- <%
- DIM objConn
- Set objConn = Server.CreateObject("ADODB.Connection")
- objConn.ConnectionString = REMOVED
- objConn.Open
- DIM mySQL
- mySQL = "SELECT * FROM UK_Specials"
- DIM objRS
- Set objRS = Server.CreateObject("ADODB.Recordset")
- objRS.Open mySQL, objConn
- %>
- <a name="LGWYYZ"></a>
- <table align="center" cellpadding="0" cellspacing="0">
- <tr>
- <td style="vertical-align:top; padding:0px 15px 0 0"><fieldset class="fieldsetspecialpricebox">
- <legend><span class="specialtitlesmall">GATWICK to TORONTO</span></legend>
- <table align="center" cellpadding="0" cellspacing="0" class="specialpricetable">
- <tr>
- <td class="priceheadertd">Price</td>
- <td class="dateheadertd">Outbound Date/s</td>
- </tr>
- <tr>
- <td colspan="2" height="10"> </td>
- </tr>
- <tr>
- <td class="pricetd">£ <% Response.Write objRS("Price_Band_1") %></td>
- <td class="datetd"><strong>March</strong> <% Response.Write objRS("Date_Band_1") %></td>
- </tr>
- <tr>
- <td class="pricetd">£ <% Response.Write objRS("Price_Band_2") %></td>
- <td class="datetd"><strong>April</strong> <% Response.Write objRS("Date_Band_2") %></td>
- </tr>
- <tr>
- <td class="pricetd">£ <% Response.Write objRS("Price_Band_3") %></td>
- <td class="datetd"><strong>May</strong> <% Response.Write objRS("Date_Band_3") %> </td>
- </tr>
- <tr>
- <td class="pricetd">£ <% Response.Write objRS("Price_Band_3") %></td>
- <td class="datetd"><strong>June</strong> <% Response.Write objRS("Date_Band_4") %> </td>
- </tr>
- <tr>
- <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>
- <td style="padding:0px 0 0 100px"><a class="button" href="#BackToTop" onclick="change_booking('LGW','YYZ')" >BOOK NOW !</a></td>
- </tr>
- </table>
- </fieldset>
- <%
- ' Don't forget to close your connection after you display your data.
- objRS.Close
- Set objRS = Nothing
- objConn.Close
- Set objConn = Nothing
- %>
- </td>
- </tr>
- </table>
- <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;'>
- <form name="UKSpecialsUpdate" method="post" action="default.asp" />
- <table align="center" width="100%" cellpadding="0" cellspacing="0" style="margin:0">
- <tr>
- <td width="30%">Price</td>
- <td>Outbound Date/s</td>
- </tr>
- <tr>
- <td><input name="ID1PriceBand1" type="text" id="ID1PriceBand1" size="4" maxlength="4" value=""></td>
- <td><input name="ID1DateBand1" type="text" id="ID1DateBand1" size="20" maxlength="100" value=""></td>
- </tr>
- <tr>
- <td><input name="ID1PriceBand2" type="text" id="ID1PriceBand2" size="4" maxlength="4" value=""></td>
- <td><input name="ID1DateBand2" type="text" id="ID1DateBand2" size="20" maxlength="100" value=""></td>
- </tr>
- <tr>
- <td><input name="ID1PriceBand3" type="text" id="ID1PriceBand3" size="4" maxlength="4" value=""></td>
- <td><input name="ID1DateBand3" type="text" id="ID1DateBand3" size="20" maxlength="100" value=""></td>
- </tr>
- <tr>
- <td><input name="ID1PriceBand4" type="text" id="ID1PriceBand4" size="4" maxlength="4" value=""></td>
- <td><input name="ID1DateBand4" type="text" id="ID1DateBand4" size="20" maxlength="100" value=""></td>
- </tr>
- <tr>
- <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>
- </div>
- </td>
- <td style="padding:20px 0 0 0" align="right"><input name="Submit" type="submit" value="Update!!" onclick="FormRedirect()"/>
- <%
- 'declare your variables
- Dim connection, sSQL, sConnString
- Price_Band_1=Request.Form("ID1PriceBand1")
- Date_Band_1=Request.Form("ID1DateBand1")
- Price_Band_2=Request.Form("ID1PriceBand2")
- Date_Band_2=Request.Form("ID1DateBand2")
- Price_Band_3=Request.Form("ID1PriceBand3")
- Date_Band_3=Request.Form("ID1DateBand3")
- Price_Band_4=Request.Form("ID1PriceBand4")
- Date_Band_4=Request.Form("ID1DateBand4")
- 'declare SQL statement that will query the database
- 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'"
- 'create an ADO connection object
- Set connection = Server.CreateObject("ADODB.connection")
- 'define the connection string, specify database
- 'driver and the location of database
- sConnString=REMOVED
- 'Open the connection to the database
- Connection.Open sConnString
- 'Execute the SQL statement
- Connection.Execute sSQL
- 'Now close the connection object
- connection.Close
- Set connection = Nothing
- %>
- </form>
- </td>
- </tr>
- </table>
- </body>
- </html>
thanks in advance
Omar.