Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > BOOK: Beginning JavaScript
|
BOOK: Beginning JavaScript
This is the forum to discuss the Wrox book Beginning JavaScript by Paul Wilton; ISBN: 9780764544057
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 13th, 2004, 10:50 AM
Authorized User
 
Join Date: Jul 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It looks like it does not pick up a value for StockId. This is the code from the form:

<input type="hidden" name="txtStockId" VALUE="<%Request.QueryString("StockId")%>">

which is supposed to retreive the StockId from the database.

 
Old July 13th, 2004, 11:05 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Request.QueryString retrieves values from the address bar, not a database.

Snib

<><
 
Old July 14th, 2004, 02:19 AM
Authorized User
 
Join Date: Jul 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry, it is suppose to retrieve it from the address bar, but it doesn't, although i can clearly see the value in the address bar.

 
Old July 14th, 2004, 04:25 AM
Authorized User
 
Join Date: Jul 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That's what the address bar looks like:

http://localhost/test_database/buyitem.asp?StockId=5

 
Old July 14th, 2004, 09:12 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Ohhhhhhhhhhh OK i see the problem now. You're missing an equals sign:

<input type="hidden" name="txtStockId" VALUE="<%Request.QueryString("StockId")%>">
should be:
<input type="hidden" name="txtStockId" VALUE="<%=Request.QueryString("StockId")%>">

Man, I can't believe I didn't catch that.... ;)

HTH,

Snib

<><
 
Old July 14th, 2004, 10:03 AM
Authorized User
 
Join Date: Jul 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Cheers Mate, that sorted it.

 
Old February 22nd, 2005, 01:43 PM
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm having the same problem. I have used the book code plus the suggested code from terry s above - still getting a syntax error problem.

Here's my code that supplies the data: -

<body bgcolor="#FFFFFF">
<p align="center">Please enter your customer ID and the number of seats you would
  like to reserve</p>
<form name="form1" language=JavaScript method="post" action="AddTable.asp" onsubmit="return form1_onsubmit()">
<input type="text" name=txtBook_ID value="<%=Request.QueryString("Booking_ID")%>">
<input type="text" name=txtDate value="<%=Request.QueryString("DateBooked")%>">
<input type="text" name=txtTime value="<%=Request.QueryString("Time")%>">
<input type="text" name=txtSeatNo value="<%=Request.QueryString("SeatsRemaining")%>" >
  <table width="700" border="1" align="center">
    <tr>
      <td>
        <div align="right">Customer ID</div>
      </td>
      <td>
        <input type="text" name="txtCustID">
      </td>
      <td>
        <div align="right">Number of Seats</div>
      </td>
      <td>
        <input type="text" name="txtSeatNo">
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <div align="center">
          <input type="reset" name="Reset" value="Reset">
        </div>
      </td>
      <td colspan="2">
        <div align="center">
          <input type="submit" name="Submit" value="Book this table">
        </div>
      </td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
<p align="center">&nbsp;</p>
<p>&nbsp; </p>
</body>

And the code on the page that inserts the data: -

<%

var ci = Request.Form("txtCustID");
var dt = Request.Form("txtDate");
var tm = Request.Form("txtTime");
var sn = Request.Form("txtSeatNo");

adoConnection = Server.CreateObject("ADODB.Connection");
adoConnection.Open("DSN=SunInnDB");

var SQL = "INSERT INTO tblBookings (CustID,Date,Time,SeatsBooked)";
SQL = SQL + "VALUES('"+ci+"','"+dt+"','"+tm+"','"+sn+"')";

adoConnection.Execute(SQL);
adoConnection.Close();
adoConnection = null;

%>

Help appreciated






Similar Threads
Thread Thread Starter Forum Replies Last Post
NEED HELP INSERT INTO statement syntax error koco ASP.NET 1.0 and 1.1 Basics 6 June 2nd, 2006 04:01 PM
Syntax error in INSERT INTO statement mega ASP.NET 1.0 and 1.1 Basics 3 January 12th, 2005 04:30 PM
Syntax error in INSERT INTO statement. askaggs Classic ASP Databases 5 June 10th, 2004 12:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.