Server-side and Client-side ?!?

  • Thread starter Thread starter Jiador
  • Start date Start date
J

Jiador

Hello,
In asp, can I to but a button in a asp page and when the user click on
it,
it add to the page a table wich contain the data of the database that
I connect?

I'm new to all of this, I think I understand that to do thing with the
database, I have to be on the server-side and to add thing on the page
by the onclick of a button, I have to be on the client-side.

So please can anybody tell me how can I do what I want ?
Thank you
Jiador
 
-----Original Message-----
Hello,
Howdy.

In asp, can I to but a button in a asp page and when the
user click on it, it add to the page a table wich
contain the data of the database that I connect?
Yes.

I'm new to all of this, I think I understand that to do
thing with the database, I have to be on the server-side
and to add thing on the page by the onclick of a button,
I have to be on the client-side.

So please can anybody tell me how can I do what I want ?

First, the form must contain a Submit button:
<input type="submit" ...>

When the visitor clicks this button, the browser
transmits the names and values of all teh elements in
that form to the server.

If the <form> tag specified method="POST", an ASP page
receives all the form element names and values in a
collection named Request.Form. So, on the server, the
expression:
Request.Form("txtCountry")
will contain the value of the following tag at the time
the visitor clicked the Submit button:
<input type="text" name="txtCountry">

Here's a simple example.

<%option explicit%>
<html>
<head>
<title>Customer Query</title>
</head>
<body>
<form method="POST">
Country:<br>
<input type="text" name="txtCountry"
value="<%=Request.Form("txtCountry")%>">
<input type="submit" value="Submit" name="btnSub">
</form>
<%
Dim strNw
Dim conNw
Dim rsNw
Dim sql
If Request.Form("btnSub") <> "" then
%>
<table>
<tr>
<th>Company Name</th>
<th>City</th>
<th>Country</th>
</tr>
<%
strNw = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & server.mappath("fpdb/fpnwind.mdb")
Set conNw = Server.CreateObject("ADODB.Connection")
conNw.open strNw

sql = "SELECT * FROM Customers " & _
"WHERE Country = '" & _
request.Form("txtCountry") & "' " & _
"ORDER BY CompanyName "
Set rsNw = Server.CreateObject("ADODB.Recordset")
rsNw.Open sql, conNw

Do While Not rsNw.eof
response.write "<tr>" & vbCrLf & _
"<td>" & rsNw("CompanyName") & "</td>" & vbCrLf & _
"<td>" & rsNw("City") & "</td>" & vbCrLf & _
"<td>" & rsNw("Country") & "</td>" & vbCrLf & _
"</tr>" & vbCrLf
rsNw.MoveNext
Loop
rsNw.Close
Set rsNw = Nothing
conNw.Close
Set conNw = Nothing
%>
</table>
<%
End If
%>
</body>
</html>

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
 
All right I think I understand now !!
I will try it right now !
Thank you very much for your help !! :-)
Jiador
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top