Solved

Passing Values to ASP script from HTML form

Posted on 2000-04-21
2
145 Views
Last Modified: 2010-04-09
HI

I have an HTML form with text input field, and also a custom button.

I want to have somebody enter a search string in the text field. When the button is pressed I want it to call an asp script, passing the text field value into a SQL query, which is within the asp script.

must be simple to do...?

thanks
0
Comment
Question by:juiceee
2 Comments
 
LVL 11

Accepted Solution

by:
thunderchicken earned 10 total points
ID: 2738131
Your ASP script must be on another page...

so you would call an ASP file, then you use

Request.Form("txtName")

then you open your SQL database with

objrec.open "SELECT * FROM whatever where varname = '" & Request.Form("txtName") & "'", objconn, 2, 2

if you need any other info, lemme know
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2739603
It indeed is simple to do, but you have to keep into account that ASP is server side and therefore this request has to be send to the server and being processed on the server, the page just has to be reloaded.

If your form looks like:

<form action="process.asp" method=post>
<input type=text name="searchstring">
<input type=submit>
</form>

then your asp file should look someting like:

<%
    Dim SearchString, Sql ...etc
    SearchString = request.form("searchstring")
    Sql = "select Name, ID from Person where Name like '%" & SearchString & "%'"
    'Open your connection here, and do all the other stuff

%>

instead of using the POST method you can also use the GET method, but thewn you can't use the request.form("..") but you should use the request.querystring(".."). Also, you don't really have to use the .form or .querystring....just request("...") is enough!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now