Click to See Complete Forum and Search --> : tricky javascript form submit error


stuu
10-09-2003, 08:31 AM
Ok, I'm really stuck with this one. I have got the task of fixing a bug in an area of our web site. All the code was written by a colleague of mine that I can no longer contact. Basically, the error occurs when clicking the 'buy me now' button whether you input a quantity or not. Below is the code which I believe is causing the problem and there's a link to an example page with the problem.

http://www.yellow-square.co.uk/productdetails.asp?p=55&k=14&C=2 (http://www.yellow-square.co.uk/productdetails2.asp?p=55&k=14&C=2)

Here's the code:

<td width="61"><input size="5" type="text" name="InputQuantity" onchange="window.document.forms['BuyNow'].Quantity.value=this.value">
</td>
<td width="116"><span style="cursor:hand"><img src="gifs/buymenow.gif" name="submit[ID]" onclick="window.document.forms['BuyNow'].ProductID.value=['ID'];window.document.forms['BuyNow'].ProductName.value=['ProductName'];window.document.forms['BuyNow'].ProductCategory.value=['Category'];window.document.forms['BuyNow'].Price.value=['ProductRetailPrice'];window.document.forms['BuyNow'].submit()">
</span></td>

and here's the form stuff:

<form id="BuyNow" name="BuyNow" action="<%=wsHomeRoot%>AddToBasket.asp?M=14" method="post">
<input type="hidden" id="Quantity" name="Quantity" value="1">
<input type="hidden" name="ProductID">
<input type="hidden" name="ProductName">
<input type="hidden" name="ProductCategory">
<input type="hidden" name="Price">
</form>

Hope the code is clear enough, you might be better off looking directly at the source code.

Let me know if I missed anything.

any help you can give me as to why the error is occuring would be greatly appreciated.

Cheers.

Fang
10-09-2003, 09:00 AM
I can not find any of the form on the page link you gave,
only a messed up html page (</body> and </html> in the middle of the page).

stuu
10-09-2003, 09:23 AM
Which browser version are you running?

Fang
10-09-2003, 09:31 AM
ie6, moz1.4 ,opera, netscape, ...
The <form> tag is nor present.

stuu
10-09-2003, 09:37 AM
I don't understand. Could you try getting to the page by starting at the home page and navigating to it? just use the shop link, pick a product and check the info.

The page works fine on every machine i've ever checked it on, but the buy now just doesn't work. Not that i'm calling you a liar, you understand, but it makes no sense that you can't see the page at all.

Fang
10-09-2003, 09:42 AM
The fact that the <form> tag is not present will not affect the page layout a great deal, but would give the error on the page.

Vladdy
10-09-2003, 09:43 AM
here is the beginning of your page. Seems like you have a lot of other errors to fix before you can even think about debugging your javascript.
( FYI: HTML 101. Document Structure
<!DOCTYPE ...>
<html>
<head>
....
</head>
<body>
....
</body>
</html>
)

God knows what kind of document structure results from this mess:

<html>


<link REL="STYLESHEET" TYPE="text/css" HREF="yellowsquare.css">
<script LANGUAGE="javascript">
<!--
function OpenProductDetails(p)
{var win2=window.open("ProductDetails.asp?p="+p,null,"resizable=yes,scrollbars=auto,height=350,width=520");}
//-->
</script>


<head>
<meta NAME="AUTHOR" Content="Stuart Coe & Paul Geare @ Yellow Square Ltd. October 2002 - January 2004">
</head>


<body leftmargin="0" topmargin="0">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
...

stuu
10-09-2003, 10:10 AM
ok, I've sorted a couple of obvious errors. one of which was entirley my fault. This is getting confusing - I'm editing .asp and .inc files, but viewing the source is obviously quite different.

Everything else on the page works fine for me. There are other javascript functions and they all work fine.

To be honest I was expecting some kind of syntax error, but this is good - keep it coming!

Fang
10-09-2003, 11:17 AM
The page generated is still a mess, check the page contents online.

stuu
10-10-2003, 05:20 AM
When you say 'a mess' I take it you mean the

ADODB.Recordset error '800a0e78'

Operation is not allowed when the object is closed.

/productdetails2.asp, line 157

error at the bottom of the page? Other than that the page is fine?

Ok, so how do I go about fixing that? The code it refers to is this:

<%
else
Response.Write "<TABLE WIDTH=95% ALIGN=center BORDER=0 CELLSPACING=1 CELLPADDING=1>" & vbCrLf
Response.Write " <TR><TD class=""FormText""><BR><BR>Sorry.<BR><BR>No additional details are currently available for this product.</TD></TR>" & vbCrLf
Response.Write "</TABLE>" & vbCrLf
end if


rsProducts.Close
set rsProducts = nothing
%>

:confused:

Vladdy
10-10-2003, 06:22 AM
You still got 2 <head>s.
The page IS a mess and will be until it at least passes this (http://validator.w3.org/check?uri=http://www.yellow-square.co.uk/productdetails2.asp?p%3D55%26k%3D14%26C%3D2&charset=(detect%20automatically)&doctype=(detect%20automatically)&verbose=1)

stuu
10-13-2003, 07:54 AM
ok, I've sorted the two heads problem. Turns out there was a .inc file that took care of the entire site's <head> information.

What else can I fix?