/    Sign up×
Community /Pin to ProfileBookmark

Hello, i would like to know how to to do error validation for listbox.
The form has a textfield, a listbox and submit button(find).

Basically the listbox is populated based on the search input in the texfield.
I would like to know how to add a message eg.( NO MATCH FOUND ) into the listbox when the search returns 0.

[code]
<%@LANGUAGE=”VBSCRIPT”%>
<!–#include file=”Include/connection.asp”–>
<%
‘test to see if site is set
TestFile(“Add”)
%>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<html>
<head>
<script language=”javascript” src=”Scriptsfieldcheck.js”></script>
<title>SLID – Select License</title>
</head>
<body onload=”document.form1.text1.value=document.form1.option1.options[document.form1.option1.selectedIndex].value”>
<%
SubTitle = “Select License”
%>
<!–#include file=”main_head.asp”–>
<DIV align=center>

<form name=”form1″ method=”post” action=””>
<P>
Software: <INPUT id=text1 name=text1 size=”10″>
<input type=”submit” name=”Submit” value=”Find”>

<%
on error goto 0

If Request.Form(“Submit”) = “Find” Then
description = Request.Form(“text1”)

set rs=Server.CreateObject(“ADODB.Recordset”)

sql= “select id,description from standard_sw where description like ‘” & description & “%'” &_
” union ” &_
” select id,name from legacy_sw where name like ‘” & description & “%'”

rs.Open sql,connStrSias

‘Response.write “SQL = “&sql
‘Response.Write Request.form

response.write “<select id=’option1′ size=’1′ name=’option1′ onchange=’this.form.text1.value=this.options[this.selectedIndex].value’>”
while not rs.EOF
response.write(“<option value='”)
response.write(rs.fields(“description”))
response.write(“‘”)

if rs.fields(“description”)= description then
response.write(“selected”)
end if

response.write(“>”)
response.write(rs.fields(“description”))
response.write(“</option>”)

rs.MoveNext
wend

response.write “</select>”
rs.Close
set rs=Nothing
End if
%>
</form></DIV>
<P align=center><INPUT type=submit value=Next name=btnSubmit onclick=”verify();”>
<!–#include file=”main_foot.asp”–>
</body>
</html>
[/code]

Thanks for the suggestions in advance.

Cheers

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@ai3rulesJan 09.2005 — Hi, I am new to asp myself. Would adding the following work?

if(rs.eof) then

response.write("NO MATCH FOUND")

end if

let me know if that does the trick.
Copy linkTweet thisAlerts:
@ai3rulesJan 09.2005 — Sorry, didn't realize you wanted the message in the list box. try:

if(rs.eof)then

response.write("<select etc..>")

'then response.write an option that says NO MATCH FOUND

response.write("</select>")

end if
×

Success!

Help @vanjamier spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...