Solved

Passing Values to ASP script from HTML form

Posted on 2000-04-21
2
148 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

717 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