christhenoob
03-13-2009, 04:02 AM
I got this email from a friend asking about some javascript but Im really new to java. can anyone help?
here is the mail:
it is a piece of java script i will insert it below and maybe you can see what i am doing wrong what i need help with is in red below you will see the comment:
<!--#include file="../includes/inc_Constants.asp"-->
<!--#include file="../includes/inc_Connect.asp"-->
<!--#include file="../includes/inc_Paging.asp"-->
<!--#include file="../includes/inc_Popup.asp"-->
<%
'REQUEST QUERYSTRING VALUES
'-------------------------------------------------------------------
Dim Search, Products
Search = Request("Search")
Products = Request("Products")
Dim Description,ProductCode,Quantity,UOM,ProductCodeId
Description = Request("Description")
ProductCode = Request("ProductCode")
Quantity = Request("Quantity")
UOM = Request("UOM")
ProductCodeId = Request("ProductCodeId")
UserId = Request.Cookies("user")("id")
'Insert into Cart
'------------------------------------------------------------------
Sub ValidInput
'SQL = "Select ProductCode,Description From ProductCodes Where ProductCodeId = '"& ProductCodeId &"'"
SQL = "sp_insert_cart" 'Add user detail to DB
SQL = SQL & "'" & UserId & "', '" & Session.SessionId & "','" & ProductCodeId & "', '" & ProductCode & "', '" & Description & "', '" & Quantity & "', '" & UOM & "', '" & DateAdd("h", +0, Now()) & "'" 'User Table Values
Response.Write SQL
Response.End
On Error Resume Next
Err.Clear
'Save User Details
Set rs = rsReadOnly(conn, SQL, True)
'Trap and display Errors
If Err.number <> 0 Then
Response.Write "<p align=""center"" style=""color:red;"">An error occurred while Adding Requisition Details:</p>" & vbcrlf
Response.Write GetSQLErrors(conn)
blnError = True
Set rs = Nothing
Exit Sub
End If
'Send User activation account details
'Create Message
Warning = 0 'False
Title = "Details Captured Successfully"
Msg = "<b>" & ProductCode & "</b>,<br><br>"
'Show Message in PopUp Message and Redirect Parent
Call PopUpWindow("products_view.asp?search=" & ProductCode, Warning, Title, Msg)
'Close Recordset
Set rs = Nothing
blnError = False
End Sub
'GET PRODUCTS
'-------------------------------------------------------------------
Sub GetProducts
SQL = "sp_search_products '" & Search & "', '" & Products & "'"
'SQL = "Select UOM From ProductCodes INNER JOIN UOM ON ProductCodes.UOMID = UOM.UOMID Where UOM.UOMId = ProductCodes.UOMId"
On Error Resume Next
Err.Clear
Set rs = rsReadOnly(conn, SQL, True)
'Trap and display Errors
If Err.number <> 0 Then
Response.Write "<p align=""center"" style=""color:red;"">An error occurred while retrieving the Products.</p>" & vbcrlf
Response.Write GetSQLErrors(conn)
blnError = True
Set rs = Nothing
Exit Sub
End If
'Page Record Count
NumPerPage = 20
rs.PageSize = NumPerPage
'Total Records
TotalRecs = rs.recordcount
'Number of pages
TotalPages = rs.PageCount
'Retrieve what page we're currently on
If Request("CurPage") = "" Then
CurPage = 1 'We're on the first page
Else
CurPage = Request("CurPage")
If CurPage < "1" Then
CurPage = 1
ElseIf CurPage - 1 > TotalPages Then
CurPage = TotalPages
Else
CurPage = CurPage
End If
End If
'Count used for cell shading
Dim Counter
Counter = 0
If TotalPages <> 0 Then rs.AbsolutePage = CurPage
If Not rs.EOF Then
Do While Not rs.EOF And Counter < rs.PageSize
'Check for dark or light background
If (Counter Mod 2) = 0 Then
Response.Write("<tr class=""shading"">")
Else
Response.Write("<tr>")
End If
Response.Write"<form>"
'Image
Response.Write "<td width=""110"" valign=""top""><a href=""javascript:PopupPic('ForWebsite/KBL/" & rs("ProductCode") & ".jpg')""><img src=""ForWebsite\KBL\" & rs("ProductCode") & ".jpg"" width=""100"" alt=""zoom"" border=""0""></a></td>" & vbCrlf
'Product
Response.Write "<td valign=""top""><input type=""hidden"" name=""description"" value=" & rs("Description") & " maxlength=""500""><b>" & rs("Description") & "</b><br>" & vbCrlf
'Sub Category
Response.Write rs("SubCategory") & "<br><br>" & vbCrlf
'Supplier
Response.Write "Supplier: " & rs("Supplier") & "<br>" & vbCrlf
'Category
Response.Write "Category: " & rs("Category") & "<br>" & vbCrlf
'Product Code
Response.Write "Product Code:<input type=""hidden"" maxlength=""13"" name=""productcode"" value="& rs("ProductCode") &">" & rs("ProductCode") & "<br><br>" & vbCrlf
'Quantity
If AddRights = True Then Response.Write "Quantity:<input name=""Quantity" & rs("ProductCodeId") & """ type=""text"" style=""width:100px; height:19px;"" onBlur=""MM_validateForm('qty','','NisNum');return document.MM_returnValue"" value=""1"" size=""6"" maxlength=""50"">" & vbCrlf
'Unit Of Measure
Response.Write "" & rs("UOM") & ""
Response.Write "</td><td width=""100"" align=""right"" valign=""bottom"">"
'add to cart
If AddRights = True Then Response.Write "<input type=""button"" value=""add to cart"" name=""Submit"" onClick=""NewWindow('products_view,asp','acepopup','640','480','custom','front');"" style=""background-color:#BE3815; color:white; width:100px; height:22px; font-weight:normal; cursor:hand; margin:1px;"" ><br>" & vbCrlf – I need to assign this button with an individual id as I am wanting to submit the data to a database as an individual record not as an entire form, I would like to call the procedure ValidInput which in written above in asp code.
'view cart
If ViewRights = True Then Response.Write "<input type=""button"" value=""view cart"" onclick=""PopUp('shopping.asp?action=viewcart','details','600','450','yes'); return false;"" style=""background-color:#BE3815; color:white; width:100px; height:22px; font-weight:normal; cursor:hand; margin:1px;""><br>" & vbCrlf
'more information
Response.Write "<input type=""button"" value=""more information"" onclick=""PopUp('details.asp?id=" & rs("ProductCodeId") & "','details','500','300','yes'); return false;"" style=""background-color:#E5E5E5; color:black; width:100px; height:22px; font-weight:normal; cursor:hand; margin:1px;""><br>" & vbCrlf
'zoom preview
Response.Write "<input type=""button"" value=""zoom preview"" onclick=""PopupPic('ForWebsite/KBL/" & rs("ProductCode") & ".jpg')"" style=""background-color:#E5E5E5; color:black; width:100px; height:22px; font-weight:normal; cursor:hand; margin:1px;""><br>" & vbCrlf
Response.Write "</td></tr><tr><td colspan=""3""><hr style=""border-top: 1px solid #E5E5E5;""></td></tr>" & vbCrlf
Counter = Counter + 1
rs.MoveNext
Loop
Else
'No records
Response.Write "<tr><td colspan=""3"" align=""center"">NO RECORDS AVAILABLE</td></tr>"
End If
response.Write"</form>"
'Show Paging
Call ShowPaging(TotalRecs, TotalPages, NumPerPage, CurPage)
'Close Recordset
Set rs = Nothing
blnError = False
End Sub
'FORM SUBMITTED - CHECK AND SAVE PRODUCT DETAILS
'-------------------------------------------------------------------
If Request("Submit") = "add to cart" Then
Call ValidInput
End If
%>
<html>
<head>
<title><%=conSiteTitle %> - Products</title>
<link href="../stylesheet/<%=conSiteTitle %>.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--#include file="../includes/inc_keywords.asp"-->
<!--#include file="../includes/inc_javascript.asp"-->
<!--#include file="../includes/inc_header.asp"-->
<!--#include file="../includes/inc_Popup.asp"-->
<!-- View/Search User -->
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" class="border" onfocus="MM_validateForm('qty','','NisNum');return document.MM_returnValue">
<tr class="shading">
<td colspan="6" align="center" style="padding:10px">
<form name="frm" action="products_view.asp" >
<form name="frm" >
SEARCH
FOR
<input type="text" name="search" maxlength="13" value="<%=Request("Search") %>">
<input type="submit" value="GO">
</td>
</tr>
<tr class="heading">
<td width="100">PRODUCT IMAGE</td>
<td width="100"><b>DESCRIPTION</b></td>
<td width="200"><b>ACTION</b></td>
<td> </td>
<td> </td>
</tr>
<% Call GetProducts %>
</form>
</table>
<!--#include file="../includes/inc_footer.asp"-->
</body>
</html>
THANKS
here is the mail:
it is a piece of java script i will insert it below and maybe you can see what i am doing wrong what i need help with is in red below you will see the comment:
<!--#include file="../includes/inc_Constants.asp"-->
<!--#include file="../includes/inc_Connect.asp"-->
<!--#include file="../includes/inc_Paging.asp"-->
<!--#include file="../includes/inc_Popup.asp"-->
<%
'REQUEST QUERYSTRING VALUES
'-------------------------------------------------------------------
Dim Search, Products
Search = Request("Search")
Products = Request("Products")
Dim Description,ProductCode,Quantity,UOM,ProductCodeId
Description = Request("Description")
ProductCode = Request("ProductCode")
Quantity = Request("Quantity")
UOM = Request("UOM")
ProductCodeId = Request("ProductCodeId")
UserId = Request.Cookies("user")("id")
'Insert into Cart
'------------------------------------------------------------------
Sub ValidInput
'SQL = "Select ProductCode,Description From ProductCodes Where ProductCodeId = '"& ProductCodeId &"'"
SQL = "sp_insert_cart" 'Add user detail to DB
SQL = SQL & "'" & UserId & "', '" & Session.SessionId & "','" & ProductCodeId & "', '" & ProductCode & "', '" & Description & "', '" & Quantity & "', '" & UOM & "', '" & DateAdd("h", +0, Now()) & "'" 'User Table Values
Response.Write SQL
Response.End
On Error Resume Next
Err.Clear
'Save User Details
Set rs = rsReadOnly(conn, SQL, True)
'Trap and display Errors
If Err.number <> 0 Then
Response.Write "<p align=""center"" style=""color:red;"">An error occurred while Adding Requisition Details:</p>" & vbcrlf
Response.Write GetSQLErrors(conn)
blnError = True
Set rs = Nothing
Exit Sub
End If
'Send User activation account details
'Create Message
Warning = 0 'False
Title = "Details Captured Successfully"
Msg = "<b>" & ProductCode & "</b>,<br><br>"
'Show Message in PopUp Message and Redirect Parent
Call PopUpWindow("products_view.asp?search=" & ProductCode, Warning, Title, Msg)
'Close Recordset
Set rs = Nothing
blnError = False
End Sub
'GET PRODUCTS
'-------------------------------------------------------------------
Sub GetProducts
SQL = "sp_search_products '" & Search & "', '" & Products & "'"
'SQL = "Select UOM From ProductCodes INNER JOIN UOM ON ProductCodes.UOMID = UOM.UOMID Where UOM.UOMId = ProductCodes.UOMId"
On Error Resume Next
Err.Clear
Set rs = rsReadOnly(conn, SQL, True)
'Trap and display Errors
If Err.number <> 0 Then
Response.Write "<p align=""center"" style=""color:red;"">An error occurred while retrieving the Products.</p>" & vbcrlf
Response.Write GetSQLErrors(conn)
blnError = True
Set rs = Nothing
Exit Sub
End If
'Page Record Count
NumPerPage = 20
rs.PageSize = NumPerPage
'Total Records
TotalRecs = rs.recordcount
'Number of pages
TotalPages = rs.PageCount
'Retrieve what page we're currently on
If Request("CurPage") = "" Then
CurPage = 1 'We're on the first page
Else
CurPage = Request("CurPage")
If CurPage < "1" Then
CurPage = 1
ElseIf CurPage - 1 > TotalPages Then
CurPage = TotalPages
Else
CurPage = CurPage
End If
End If
'Count used for cell shading
Dim Counter
Counter = 0
If TotalPages <> 0 Then rs.AbsolutePage = CurPage
If Not rs.EOF Then
Do While Not rs.EOF And Counter < rs.PageSize
'Check for dark or light background
If (Counter Mod 2) = 0 Then
Response.Write("<tr class=""shading"">")
Else
Response.Write("<tr>")
End If
Response.Write"<form>"
'Image
Response.Write "<td width=""110"" valign=""top""><a href=""javascript:PopupPic('ForWebsite/KBL/" & rs("ProductCode") & ".jpg')""><img src=""ForWebsite\KBL\" & rs("ProductCode") & ".jpg"" width=""100"" alt=""zoom"" border=""0""></a></td>" & vbCrlf
'Product
Response.Write "<td valign=""top""><input type=""hidden"" name=""description"" value=" & rs("Description") & " maxlength=""500""><b>" & rs("Description") & "</b><br>" & vbCrlf
'Sub Category
Response.Write rs("SubCategory") & "<br><br>" & vbCrlf
'Supplier
Response.Write "Supplier: " & rs("Supplier") & "<br>" & vbCrlf
'Category
Response.Write "Category: " & rs("Category") & "<br>" & vbCrlf
'Product Code
Response.Write "Product Code:<input type=""hidden"" maxlength=""13"" name=""productcode"" value="& rs("ProductCode") &">" & rs("ProductCode") & "<br><br>" & vbCrlf
'Quantity
If AddRights = True Then Response.Write "Quantity:<input name=""Quantity" & rs("ProductCodeId") & """ type=""text"" style=""width:100px; height:19px;"" onBlur=""MM_validateForm('qty','','NisNum');return document.MM_returnValue"" value=""1"" size=""6"" maxlength=""50"">" & vbCrlf
'Unit Of Measure
Response.Write "" & rs("UOM") & ""
Response.Write "</td><td width=""100"" align=""right"" valign=""bottom"">"
'add to cart
If AddRights = True Then Response.Write "<input type=""button"" value=""add to cart"" name=""Submit"" onClick=""NewWindow('products_view,asp','acepopup','640','480','custom','front');"" style=""background-color:#BE3815; color:white; width:100px; height:22px; font-weight:normal; cursor:hand; margin:1px;"" ><br>" & vbCrlf – I need to assign this button with an individual id as I am wanting to submit the data to a database as an individual record not as an entire form, I would like to call the procedure ValidInput which in written above in asp code.
'view cart
If ViewRights = True Then Response.Write "<input type=""button"" value=""view cart"" onclick=""PopUp('shopping.asp?action=viewcart','details','600','450','yes'); return false;"" style=""background-color:#BE3815; color:white; width:100px; height:22px; font-weight:normal; cursor:hand; margin:1px;""><br>" & vbCrlf
'more information
Response.Write "<input type=""button"" value=""more information"" onclick=""PopUp('details.asp?id=" & rs("ProductCodeId") & "','details','500','300','yes'); return false;"" style=""background-color:#E5E5E5; color:black; width:100px; height:22px; font-weight:normal; cursor:hand; margin:1px;""><br>" & vbCrlf
'zoom preview
Response.Write "<input type=""button"" value=""zoom preview"" onclick=""PopupPic('ForWebsite/KBL/" & rs("ProductCode") & ".jpg')"" style=""background-color:#E5E5E5; color:black; width:100px; height:22px; font-weight:normal; cursor:hand; margin:1px;""><br>" & vbCrlf
Response.Write "</td></tr><tr><td colspan=""3""><hr style=""border-top: 1px solid #E5E5E5;""></td></tr>" & vbCrlf
Counter = Counter + 1
rs.MoveNext
Loop
Else
'No records
Response.Write "<tr><td colspan=""3"" align=""center"">NO RECORDS AVAILABLE</td></tr>"
End If
response.Write"</form>"
'Show Paging
Call ShowPaging(TotalRecs, TotalPages, NumPerPage, CurPage)
'Close Recordset
Set rs = Nothing
blnError = False
End Sub
'FORM SUBMITTED - CHECK AND SAVE PRODUCT DETAILS
'-------------------------------------------------------------------
If Request("Submit") = "add to cart" Then
Call ValidInput
End If
%>
<html>
<head>
<title><%=conSiteTitle %> - Products</title>
<link href="../stylesheet/<%=conSiteTitle %>.css" rel="stylesheet" type="text/css">
</head>
<body>
<!--#include file="../includes/inc_keywords.asp"-->
<!--#include file="../includes/inc_javascript.asp"-->
<!--#include file="../includes/inc_header.asp"-->
<!--#include file="../includes/inc_Popup.asp"-->
<!-- View/Search User -->
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" class="border" onfocus="MM_validateForm('qty','','NisNum');return document.MM_returnValue">
<tr class="shading">
<td colspan="6" align="center" style="padding:10px">
<form name="frm" action="products_view.asp" >
<form name="frm" >
SEARCH
FOR
<input type="text" name="search" maxlength="13" value="<%=Request("Search") %>">
<input type="submit" value="GO">
</td>
</tr>
<tr class="heading">
<td width="100">PRODUCT IMAGE</td>
<td width="100"><b>DESCRIPTION</b></td>
<td width="200"><b>ACTION</b></td>
<td> </td>
<td> </td>
</tr>
<% Call GetProducts %>
</form>
</table>
<!--#include file="../includes/inc_footer.asp"-->
</body>
</html>
THANKS