brodemeyer
Programmer
I have an asp page that is basically suppose to work like eBay where the user enters a bid and their name. The asp page is calling a javascript function. The page works fine meaning the user can bid on an item and the database is updated however I am trying to validate the bid as to that it is at least $1.00 above the current bid. Right now I have placed a window.alert message at the top of the function and it is not appearing so the function is not being entered at all. Looking at the code below can anyone see anything wrong? I am a beginner so I apologize if the code is sloppy, any suggestions is appreciated. Thanks.
Here is the code:
<html>
<head>
<title>United Way Bank-Bay</title>
</head>
<body><%
Session.timeout = 5
If IsObject(Session("Auction_conn"
) Then
Set conn = Session("Auction_conn"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Else
Set conn = Server.CreateObject("ADODB.Connection"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
conn.open "Auction"
Set Session("Auction_conn"
= conn
End If
%>
<%
If IsObject(Session("Auction_rs"
) Then
Set rs = conn.Execute("SELECT * FROM Auction WHERE ItemName = 'Notebook'"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
'Set rs = Session("Auction_rs"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Else
sql = "SELECT * FROM Auction WHERE ItemName = 'Notebook'"
Set rs = Server.CreateObject("ADODB.Recordset"![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
rs.Open sql, conn, 3, 3
If rs.eof Then
rs.AddNew
End If
Set Session("Auction_rs"
= rs
End If
%>
<script type="jscript">
function validate()
{
window.alert("In Function!"
;
if(<%=Server.HTMLEncode(rs.Fields("HighBid"
.Value)%> < document.Form1.NewHighBid.value)
{
window.alert("Please enter a value greater than the current bid."
;
document.Form1.NewHighBid.focus();
return false;
}
if(document.Form1.NewHighBidder.value == ""![Wink ;) ;)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
{
window.alert("Please enter your name."
;
document.Form1.NewHighBidder.focus();
return false;
}
}
</script>
<table style="WIDTH: 769px; HEIGHT: 72px">
<link rel="STYLESHEET" type="text/css" href="../dhtmlcentral.css">
<script language="JavaScript1.2" src="../coolmenus4.js">
</script>
<tr align="left">
<td height="65" background="../images/topbar.bmp"><FONT
size=6>
</FONT>
<A href=" height=39 alt="" src="../images/home.bmp" width=80 border=0></A></td>
</tr>
</table>
<table style="WIDTH: 769px; HEIGHT: 356px">
<tr><!--Left Side-->
<td width="22%" height="350" align="middle" valign="top" bgcolor="aac6e1"></td><!--Text Area-->
<td width="565" height="350" valign="top"><BR>
<br><!--Start Typing Here-->
<form name="Form1" onSubmit="return validate();" ACTION="update.asp" METHOD="POST">
<div align="left"><p>Welcome. Please place a bid on the item below.<br>
</p>
</div><blockquote>
<div align="center"><div align="center"><center><table border="1" width="512" height="78">
<%
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
%>
<tr>
<td width="83" height="7">Item Name</td>
<td width="417" height="7"><%=Server.HTMLEncode(rs.Fields("ItemName"
.Value)
%></td>
</tr>
<tr>
<td width="83" height="7">Donator(s)</td>
<td width="417" height="7"><%=Server.HTMLEncode(rs.Fields("Donator"
.Value)%></td>
</tr>
<tr>
<td width="83" height="7">Current High Bid</td>
<td width="417" height="7"><%=Server.HTMLEncode(rs.Fields("HighBid"
.Value)%></td>
</tr>
<tr>
<td width="83" height="7">Current High Bidder</td>
<td width="417" height="7"><%=Server.HTMLEncode(rs.Fields("HighBidder"
.Value)%></td>
</tr>
<tr>
<td width="83" height="7">Your High Bid</td>
<td width="417" height="7"><input type="text" name="NewHighBid" size="20"></td>
</tr>
<tr>
<td width="83" height="7">Your Name</td>
<td width="417" height="7"><input type="text" name="NewHighBidder" size="20"></td>
</tr>
<input type="hidden" name="ItemName" value="Notebook">
<%
rs.MoveNext
loop%>
</table>
</center></div><div align="center"><center><table>
<tr>
<td><div align="center"><center><p><input TYPE="SUBMIT" VALUE="Update"></td>
</tr>
</table>
</center></div></div>
</blockquote>
</form>
</P></table><!--Don't Type Past Here-->
</td>
</tr>
</table>
</body>
</html>
Here is the code:
<html>
<head>
<title>United Way Bank-Bay</title>
</head>
<body><%
Session.timeout = 5
If IsObject(Session("Auction_conn"
Set conn = Session("Auction_conn"
Else
Set conn = Server.CreateObject("ADODB.Connection"
conn.open "Auction"
Set Session("Auction_conn"
End If
%>
<%
If IsObject(Session("Auction_rs"
Set rs = conn.Execute("SELECT * FROM Auction WHERE ItemName = 'Notebook'"
'Set rs = Session("Auction_rs"
Else
sql = "SELECT * FROM Auction WHERE ItemName = 'Notebook'"
Set rs = Server.CreateObject("ADODB.Recordset"
rs.Open sql, conn, 3, 3
If rs.eof Then
rs.AddNew
End If
Set Session("Auction_rs"
End If
%>
<script type="jscript">
function validate()
{
window.alert("In Function!"
if(<%=Server.HTMLEncode(rs.Fields("HighBid"
{
window.alert("Please enter a value greater than the current bid."
document.Form1.NewHighBid.focus();
return false;
}
if(document.Form1.NewHighBidder.value == ""
{
window.alert("Please enter your name."
document.Form1.NewHighBidder.focus();
return false;
}
}
</script>
<table style="WIDTH: 769px; HEIGHT: 72px">
<link rel="STYLESHEET" type="text/css" href="../dhtmlcentral.css">
<script language="JavaScript1.2" src="../coolmenus4.js">
</script>
<tr align="left">
<td height="65" background="../images/topbar.bmp"><FONT
size=6>
</FONT>
<A href=" height=39 alt="" src="../images/home.bmp" width=80 border=0></A></td>
</tr>
</table>
<table style="WIDTH: 769px; HEIGHT: 356px">
<tr><!--Left Side-->
<td width="22%" height="350" align="middle" valign="top" bgcolor="aac6e1"></td><!--Text Area-->
<td width="565" height="350" valign="top"><BR>
<br><!--Start Typing Here-->
<form name="Form1" onSubmit="return validate();" ACTION="update.asp" METHOD="POST">
<div align="left"><p>Welcome. Please place a bid on the item below.<br>
</p>
</div><blockquote>
<div align="center"><div align="center"><center><table border="1" width="512" height="78">
<%
On Error Resume Next
rs.MoveFirst
do while Not rs.eof
%>
<tr>
<td width="83" height="7">Item Name</td>
<td width="417" height="7"><%=Server.HTMLEncode(rs.Fields("ItemName"
%></td>
</tr>
<tr>
<td width="83" height="7">Donator(s)</td>
<td width="417" height="7"><%=Server.HTMLEncode(rs.Fields("Donator"
</tr>
<tr>
<td width="83" height="7">Current High Bid</td>
<td width="417" height="7"><%=Server.HTMLEncode(rs.Fields("HighBid"
</tr>
<tr>
<td width="83" height="7">Current High Bidder</td>
<td width="417" height="7"><%=Server.HTMLEncode(rs.Fields("HighBidder"
</tr>
<tr>
<td width="83" height="7">Your High Bid</td>
<td width="417" height="7"><input type="text" name="NewHighBid" size="20"></td>
</tr>
<tr>
<td width="83" height="7">Your Name</td>
<td width="417" height="7"><input type="text" name="NewHighBidder" size="20"></td>
</tr>
<input type="hidden" name="ItemName" value="Notebook">
<%
rs.MoveNext
loop%>
</table>
</center></div><div align="center"><center><table>
<tr>
<td><div align="center"><center><p><input TYPE="SUBMIT" VALUE="Update"></td>
</tr>
</table>
</center></div></div>
</blockquote>
</form>
</P></table><!--Don't Type Past Here-->
</td>
</tr>
</table>
</body>
</html>