Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User side Validation

Status
Not open for further replies.

svsuthar1

Programmer
Jul 6, 2004
135
US
I have a form that loops through recordset and creates a it's Name... I want to write a javascript that will check field some #.Price to see if it is NULL if it is then it will give alert saying that this field can't be null please input the price and set foucs to that field.

here is my current code and I am not sure how I can do this since the name property of that filed is created when the page is loaded.

<LINK href="..\CSS\plone.css" type=text/css rel=stylesheet>
<FORM NAME=getInventory METHOD=post ACTION="saveInventory.asp">
<TABLE cellSpacing=0 cellPadding=1 border=1 align=center bordercolor="#CCCCCC" style='border-collapse:collapse;'>
<TR><TD align=center><B>Order #</B></TD>
<TD align=center><B>Product Name</B></TD>
<TD align=center><B>Price</B></TD>
<TD align=center><B>Quantity</B></TD>
<TD align=center><B>Action</B></TD>
<TD align=center><B>Order Date</B></TD>
</TR><BR>
<%
'Open up a connection our access database
'we will use a DSN-less connection

'Create a path for the database
Dim objConn, path
path="C:\Inetpub\
'Create a Connection using the path given above
Set objconn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString= "PROVIDER=MICROSOFT.JET.OLEDB.4.0;" & _
"DATA SOURCE=" & path
objConn.Open

'Create the SQL to be used for it to display
Dim strSQL, strSQL1, objRS, objRS1, iCount, ID, Code
iCount = 0
strSQL = "SELECT tblProducts.fldProductID, tblProducts.fldOrderNum, tblProducts.fldProductName, tblProducts.fldActive, tblCategory.fldCategoryID " _
& "FROM tblCategory INNER JOIN tblProducts ON tblCategory.fldCategoryID = tblProducts.fldCategoryID " _
& "WHERE (((tblProducts.fldActive)=Yes) AND ((tblCategory.fldCategoryID)=" & Request.QueryString("CategoryID")& ")) " _
& "Order By fldProductName;"

strSQL1 = "SELECT fldActionID, fldActionName " _
& "FROM tblAction"

'Create a recordset of the SQL that is created above
Set objRS = Server.CreateObject("ADODB.Recordset")
'Set objRS1 = Server.CreateObject("ADODB.Recordset")
objRS.Open strSQL, objConn,3,3
'objRS1.Open strSQL1, objConn,3,3

'loop through all the records outputting a row for each one
Do Until objRS.EOF
Response.Write("<TR>")
Response.Write("<Input Type=Hidden Name=""" & iCount & ".ID"" " & _
"Value=""" & objRS("fldProductID") & """>")
Response.Write("<TD align=Center>" & objRS("fldOrderNum") & "</TD>")
Response.Write("<TD>" & objRS("fldProductName") & "</TD>")
Response.Write("<TD><input type=text name=""" & _
iCount & ".Price"" Value="""" STYLE=text-align:center Size=7 onblur=""ChangeVal(this);""</TD>")
Response.Write("<TD><input type=text name=""" & _
iCount & ".Quantity"" Value="""" STYLE=text-align:center Size=7></TD>")
Response.Write("<TD><Select name=""" & iCount & ".Action"">")
Set objRS1 = Server.CreateObject("ADODB.Recordset")
objRS1.Open strSQL1, objConn,3,3
Do Until objRS1.EOF
ID1 = objRS1("fldActionID")
Code = objRS1("fldActionName")
response.write("<option value='" & ID1 & "'>" & Code & "</option>")
objRS1.movenext
Loop
response.write("</select></td>")
objRS1.Close
set objRS1 = nothing
Response.Write("<TD><input type=text name=""" & _
iCount & ".Date"" Value="&Date&" STYLE=text-align:center Size=12></TD>")

'Response.Write("<TD><input type name=""" & iCount & ".Date"" Value= & Res>
'Response.Write("<TD><input type=text name=""" & _
' iCount & ".Date"" Value=" &Date& ">&nbsp;<A href=""javascript:ShowDate('getInventory.iCount & ".Date"',this.getInventory.iCount & ".Date".value)""><IMG src=""..\images\help.gif"" align=middle border=0></A></TD>")
Response.Write("</TR>")
objRS.MoveNext
iCount = iCount + 1
Loop
'Clean up our ADO objects
objRS.Close
Set objRS = Nothing

objConn.Close
Set objConn = Nothing
Response.Write "<TR><TD Align=Center colspan=6><INPUT TYPE=BUTTON VALUE=""Submit"" ONCLICK=""SaveOrder();"" id=BUTTON1 name=BUTTON1></TD></TR>"
Response.Write "<INPUT TYPE=HIDDEN NAME=Count VALUE=" & iCount - 1 & "></FORM></TABLE>
 
Can you show the result (open the page and hid View Source)?

--Chessbot

"See the TURTLE of enormous girth!"
-- Stephen King, The Dark Tower series
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top