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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

client and server side script in the same function.

Status
Not open for further replies.

ganusha

Programmer
May 1, 2002
28
US
hi
i've a find page wherein you have to enter a name and find the address for the name in the database .
i've to first validate in the client side if the textbox is left empty and if not then connect to the database and find the record.
i've created a textbox and a find button and in the onclick event i call the function check which checks if the text box is blank properly.
but how do i write the else part where i've to connect and search the database.



<script language=vbscript>
sub check()

if document.find.text1.value=&quot;&quot; then
msgbox &quot;Enter some name to find the corresponding
address.&quot;
else
<%
session(&quot;Connection&quot;)= &quot;Provider=SQLOLEDB.1;Persist
Security Info=False;User ID=sa;Initial
Catalog=EPersonalAssistant;Data Source=GANUSHA-
HS4QTTQ&quot;

dim objconn,objrs,strSql,strName

set objconn=server.CreateObject(&quot;adodb.connection&quot;)
objconn.Open session(&quot;Connection&quot;)
set objrs=server.CreateObject(&quot;adodb.recordset&quot;)
strSql=&quot;select * from addressbook where name ??
objrs.Open strSql,objconn

%>
end if
end sub
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top