473,396 Members | 1,966 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,396 software developers and data experts.

Update values without Page Refresh

6
Hi,

I'm very much a novice, and wondered if someone could help. I'll try to be as specific as possible, but don't waant you to have to read too much.

I have 2 pages in the sequence. 1st allows customers to login, passing control to the 2nd, which on entry returns their balance details from my DB (using their Reference 'BookingRef = Request.form("txtBookingRef")') and displays an additional section allowing them to enter an amount of a part payment, which supsequently passes them to my PayPal account (Form2).

The main purpose is that on the 2nd page, a value is entered, the update button clicked, other values on the page are updated, i.e.
Enter Amount (Input field)
- update button -
'Amount Entered' asp calculated field
'CC Charge' asp calculated field
'Total Amount' asp calculated field
I have both pages working ok (individually, i.e. hardcoding the BookingRef on the 2nd page), but when I pass it from page 1 and when I click the update button after entering a value, the complete page is refreshed, and the Reference is lost, with the page returning the following error 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1' + referring to the line number of my 'rs.Open sqlStr, conn'.

1. I would prefer to keep it in asp. Is there any way I can retain my BookingRef passed from page 1 when I update the other values?

2. I have changed Page2 & tried javascript, using onChange, which works ok, but I can't work out how to get the 'Total Amount' value to my Hidden PayPal form also ( I can get it to the 'Total Amount' ok - as it is in the same form)

I would really appreciate any suggestions for #1

If #1 is not possible, can you help with #2

thanks, Michael

PS - I should have mentioned, that I am NOT posting the amount entered back to the DB - I do that manually myself via different pages, as I need to allocate it differently.
Oct 26 '07 #1
8 4494
jhardman
3,406 Expert 2GB
1- To keep data with a user through multiple pages, I prefer to use session-level variables
Expand|Select|Wrap|Line Numbers
  1. if request.form("txtBookingRef") <> "" then
  2.    session("BookingRef") = Request.form("txtBookingRef")
  3. end if
this can then be accessed on every page the user visits.

2- This is kind of a javascript issue. I'm not an expert in javascript but I could probably get it to work. I would need to see your code though.

Let me know if this helps.

Jared
Oct 28 '07 #2
m1post
6
Thanks Jared,
I'll stick with the asp option if I can get it to work.
Here's the code I'm using to get the details back from the DB
----------------
BookingRef = Request.form("txtBookingRef")
sqlStr = " SELECT td.task_detail_id_int"
sqlStr = sqlStr & " FROM task_detail td"
sqlStr = sqlStr & " JOIN booking b ON td.booking_id_int = b.booking_id_int"
sqlStr = sqlStr & " WHERE status_id_int = 1 and b.booking_ref_vch = " + cstr(BookingRef)

conn.Open
rs.Open sqlStr, conn
TaskID = rs("task_detail_id_int")
conn.Close
---------------
I then use the TaskID to pull back all the client, payment, Booking Status, etc. from an include file.

where should I insert the session-level code?

Thanks again, Michael
Oct 30 '07 #3
markrawlingson
346 Expert 100+
If BookingRef is what you want to be able to access from any page, then you would insert it like so...

Expand|Select|Wrap|Line Numbers
  1. Session("BookingRef") = Request.form("txtBookingRef")
  2. sqlStr = " SELECT td.task_detail_id_int"
  3. sqlStr = sqlStr & " FROM task_detail td"
  4. sqlStr = sqlStr & " JOIN booking b ON td.booking_id_int = b.booking_id_int"
  5. sqlStr = sqlStr & " WHERE status_id_int = 1 and b.booking_ref_vch = " + cstr(Session("BookingRef"))
  6.  
  7. conn.Open 
  8. rs.Open sqlStr, conn
  9. TaskID = rs("task_detail_id_int")
  10. conn.Close
  11.  
Instead of storing the information from Request.Form("txtBookingRef") in a variable which can only be used within this script, you set it into a Session variable named Session("BookingRef") which is stored in the server's memory, and thus can be accessed again on any page simply by referring to it...

Expand|Select|Wrap|Line Numbers
  1. Response.Write "Your bookingref = " & Session("BookingRef")
  2.  
Oct 31 '07 #4
m1post
6
Thanks Mark.

I've tried all variations, but still can't get it to hold the BookingRef in the session.
Error message below - I'm using a MySQL DB, so not sure if that makes any difference?
---------------------------------------
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[MySQL][ODBC 3.51 Driver][mysqld-5.0.27-standard-log]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''
------------------------------------
I only get this error message when I attempt to update the details on the page. When I load it first, I can get all details back from the DB ok.

hope you can help.

thanks, Michael
Oct 31 '07 #5
m1post
6
It's the update <form> that seems to be causing the problem.
If I just referesh the page - fine.
If I click the Update button (within the <form>) I get the above error, so I am loosing the "BookingRef" at that stage.

(the update <form> takes the Payment Amount Entered, updates/displays the Payment Amount Entered (to a seperate field), Updates/displays the Credit Card Charge & the Total Amount to be charged.

But the <form> does not actually use/hold the BookingRef.

Thanks, Michael
Nov 1 '07 #6
markrawlingson
346 Expert 100+
Hi Michael,

Show the update statement.
Nov 1 '07 #7
m1post
6
Hi Chris,

I've stripped all the other details out, except the Update <form>. which works ok in itself, but I get the above error when I try the update with all the other details, i.e. the BookingRef, etc from the previous page & DB.

Thanks, Michael

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.     <script language="javascript">            
  4.             function ValidateForm()
  5.             {
  6.                 var rtnStr = "";
  7.                 var vCtrl = "";
  8.  
  9.             if(document.frmUpdatePartPayform.AmountEntered.value == "")
  10.                 {
  11.                     rtnStr = rtnStr + " - Please enter Payment Amount.\n"
  12.                     if (vCtrl == "")
  13.                     {
  14.                         vCtrl = "AmountEntered";
  15.                     }
  16.                 }
  17.  
  18.             if ((document.frmUpdatePartPayform.AmountEntered.value.length > 0) && (isNaN(document.frmUpdatePartPayform.AmountEntered.value*(-1)*(-1))))
  19.                 {
  20.                     rtnStr = rtnStr + " - Please enter a numeric Payment Value.\n"
  21.                     if (vCtrl == "")
  22.                     {
  23.                         vCtrl = "AmountEntered";
  24.                     }
  25.                 }
  26.             if (rtnStr != "")
  27.                 {
  28.                     alert(rtnStr)
  29.                     document.getElementById(vCtrl).focus()
  30.                     return false;        
  31.                 }
  32.                 else
  33.                 {
  34.                     return true;
  35.                 }
  36.             }    
  37. </script>
  38. <%
  39. cc_percent_charge = 0.035
  40. AmountEntered = Request.Form("AmountEntered")
  41.  
  42.     If AmountEntered = "" then CC_Charge = FormatNumber((0),2)
  43.     If AmountEntered = "" then Display_CC_Charge = FormatNumber((0),2)
  44.     If AmountEntered = "" then Display_AmountEntered = FormatNumber((0),2)
  45.     If AmountEntered <> "" then CC_Charge = (AmountEntered * cc_percent_charge)
  46.     If AmountEntered <> "" then Display_CC_Charge = FormatNumber((CC_Charge),2)
  47.     If AmountEntered <> "" then Display_AmountEntered = FormatNumber((AmountEntered),2)
  48.  
  49.     TotalToPay = (AmountEntered + CC_Charge)
  50.     Display_TotalToPay = FormatNumber((TotalToPay),2)
  51. %>
  52.         <table>    
  53.         <form name="frmUpdatePartPayform" method="post"  onsubmit="return ValidateForm();" ID="Form1">
  54.             <tr>
  55.                 <td NOWRAP>
  56.                     Enter the Payment Amount
  57.                 </td>
  58.                 <td >
  59.                     <input size="4" name="AmountEntered">
  60.                 </td>
  61.             </tr>
  62.             <tr >
  63.                 <td NOWRAP >
  64.                     <input valign="middle" class="button"  type="submit" value="Click Here To Update">
  65.                 </td>
  66.             </tr>
  67.             <tr>
  68.                 <td NOWRAP >
  69.                     <b>Amount Entered</b>
  70.                 </td>
  71.                 <td>
  72.                     <b><%=Display_AmountEntered%></b>
  73.                 </td>
  74.             </tr>
  75.             <tr>
  76.                 <td NOWRAP>
  77.                     <b>Processing Charge </b>
  78.                 </td>
  79.                 <td >
  80.                     <%=Display_CC_Charge%>
  81.                 </td>
  82.             </tr>
  83.             <tr>
  84.                 <td NOWRAP>
  85.                     <b>Total to Pay on this Transaction</b>
  86.                 </td>
  87.                 <td >
  88.                     <b><%=Display_TotalToPay%></b>
  89.                 </td>
  90.             </tr>
  91.         </form>    
  92.         </table>
  93.     </body>
  94. </html>
  95.  
  96.  
Nov 2 '07 #8
m1post
6
Sorry Mark,

I realised I hadn't included the 2nd <form> that is (needed to be) updated to go out to my PayPal account

Thanks, Michael

Expand|Select|Wrap|Line Numbers
  1. <form action="https://www.paypal.com/cgi-bin/webscr" method="post" ID="Form2">
  2.     <input type="hidden" name="amount" value="<%=Display_TotalToPay%>" ID="Hidden16">
  3.     <input class="button" type="submit" name="submit" value="Proceed to Payment" ID="Submit2">
  4. </form>    
  5.  
  6.  
Nov 6 '07 #9

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

Similar topics

3
by: Kevin Pedersen | last post by:
Hello, I am using an editable datagrid. After I save the changes the datagrid shows the old values. I've read the posts about the Page_Load and not binding the datagrid each time. The SQL that...
9
by: Chris | last post by:
I pop up a Modal form on a web page that allows the user to update the selections of a dropdownlist via adding a new item to the db (Sql Server).The only thing is this list is on the page beneath...
1
by: nospamjac | last post by:
Hi, Is there a way to update the text of an asp:label on a webform without refreshing the entire page? What is called by button clicks and other events that refresh a webform control? See the...
1
by: cguillot | last post by:
Hello, I have a web page that displays information from a SQL database and this information can change frequently. Basically, a database entry is made into a table every time a person enters or...
4
by: Jim Hammond | last post by:
It would be udeful to be able to get the current on-screen values from a FormView that is databound to an ObjectDataSource by using a callback instead of a postback. For example: public void...
8
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
0
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase...
3
by: laryten | last post by:
Hi, Is there a way to update the same web page instead of getting a new page each time we click the submit button? The simplest thing to do is to delete the current page (or go back to the...
5
by: handoyo | last post by:
Hi all,i'm trying to show updated data in existing html td.. For example i got column that show last modified datetime,then i want to update data again,the column will changed to current time without...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.