Click to See Complete Forum and Search --> : help please


kimstar00
10-20-2006, 09:42 PM
I'm new ASP and i'm having trouble with linking two asps. :confused:
I have a search page, from this search page i click on a radio button and type the data that i'm looking for in, once i submit this entry i want to make it so that if for example "orders by customer number" was selected and i type something other than the customer number it gives me an error saying that the value is wrong/the value isnt numeric. I've tried doing this but it doesnt work. I dont kno why.

asp file 1 (search.asp)
<%@ Language="VBScript" %>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title>Search Page</title>
<meta name="description" content="Search Page"/>
<link href="Assign2.css" rel="stylesheet" type="text/css"/>
</head>

<body>
<form id="search" action="process.asp?open=1" method="post">
<h1>Search Page</h1>
<table border="1">
<tr>
<td><input type="radio" name="searchoption" id="bylastname" value="1"/> Orders by Customer Last Name<br/></td>
<td><input type="radio" name="searchoption" id="bycustomerno" value="2"/>Orders by Customer Number<br/></td>
<td><input type="radio" name="searchoption" id="bydate" value="3"/> Orders by Date<br/></td>
<td><input type="radio" name="searchoption" id="byorderno" value="4"/> Orders by Order Number<br/></td>
</tr>
</table>
<input type="text" name="searchfld" size="121"/><br/>
<hr>
<input type="radio" name="searchoption" id="byshipping" value="5"/> Shipped (no input required)<br/>
<input type="submit" value="Search"/><input type="reset" value="Reset"/>
</form>
</body>
</html>


asp file 2 (process.asp)
<html>
<body>
searched = request.form("searchfld")
selected = request.form("searchoption")
<%
if selected = 2 then
number = request.form("searchfld")
' check what was entered before processing
if IsNumeric(searchfld) then
number = int(searchfld)
if number < 100000 or number > 999999 then
response.write("The data was not in the required range")
end if
else
response.write("Data entered was not numeric")
end if
%>


</body>
</html>

I.m.I
10-21-2006, 07:47 PM
plz change the process.asp

<html>
<body>

<%
searched = request.form("searchfld")
selected = request.form("searchoption")
if selected = 2 then
' check what was entered before processing

if IsNumeric(searched) then
if searched < 100000 or searched > 999999 then
response.write("The data was not in the required range")
end if
else
response.write("Data entered was not numeric")
end if
end if
%>


</body>
</html>

kimstar00
10-21-2006, 08:10 PM
oh wow! Thanks :D

But i hav one more question. How do i make the error message display in the search.asp page? I'm pretty sure i need to use response.redirect, but i couldnt get it working :(

I.m.I
10-21-2006, 08:29 PM
u can make client script validation using javascript

first create javascript function

function isNumeric(val){
str="0123456789."
len=val.length
for(i=0;i<len;i++)
{
ch=val.charAt(i)

if(str.indexOf(ch)==-1)
{
alert("please insert only number")
return false
}
}


return true
}


and then change the submit button to :
<input type="submit" value="Search" onclick=" return isNumeric(documents.forms[0].elements["searchfld"].value)/>

kimstar00
10-21-2006, 08:57 PM
oh alrite thanks

but is there any other way of doing it without using javascript. i dun really like javascript lol

like using response.redirect

I.m.I
10-22-2006, 04:28 AM
ok try this
<%
if request.form("sub")="Search" then
searched = request.form("searchfld")
selected = request.form("searchoption")
if selected = 2 then
' check what was entered before processing

if IsNumeric(searched) then
if searched < 100000 or searched > 999999 then
response.write("The data was not in the required range")
end if
else
response.write("Data entered was not numeric")
end if
end if
end if
%><body>
<form id="search" action="" method="post">
<h1>Search Page</h1>
<table border="1">
<tr>
<td><input type="radio" name="searchoption" id="bylastname" value="1"/> Orders by Customer Last Name<br/></td>
<td><input type="radio" name="searchoption" id="bycustomerno" value="2"/>Orders by Customer Number<br/></td>
<td><input type="radio" name="searchoption" id="bydate" value="3"/> Orders by Date<br/></td>
<td><input type="radio" name="searchoption" id="byorderno" value="4"/> Orders by Order Number<br/></td>
</tr>
</table>
<input type="text" name="searchfld" size="121"/><br/>
<hr>
<input type="radio" name="searchoption" id="byshipping" value="5"/> Shipped (no input required)<br/>
<input type="submit" value="Search" name="sub" /><input type="reset" value="Reset"/>
</form>
</body>

vijay.1980
10-24-2006, 11:53 AM
i need a code in asp for next button for retrieving the table of database upto end record by clicking next record and need a code to get first record of the table by clicking top button.