By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,723 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,723 IT Pros & Developers. It's quick & easy.

Update values without Page Refresh

P: 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
Share this Question
Share on Google+
8 Replies


jhardman
Expert 2.5K+
P: 3,405
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

P: 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
Expert 100+
P: 346
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

P: 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

P: 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
Expert 100+
P: 346
Hi Michael,

Show the update statement.
Nov 1 '07 #7

P: 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

P: 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

Post your reply

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