Form Actions

J

JasonLFunk

The form action is just the name of the page. My Form looks like this

<form name="hidden" method="Post" action="scholarshipselection.asp"><input type="hidden" name="StudentID"><input type="hidden" name="Password"></form

I set the values of the hidden forms with Javascript from imformation from a cookie. I want to use those two forms as my Database Critera Search Results which uses the webbot. I want the page to think that the user entered the two values and pushed the submit button when the page loads so the data is automatically there. But I dont want a submit button or the textbox. I added a line in my javascript like this 'document.hidden.submit()' and it got recursive I guess and kept reloading itself over and over agian. Help Pleas
 
J

Jon Spivey

Hi,
you'd probably be better reading the cookie and setting the values with ASP,
then you can submit the form with javascript, eg
<form name="hidden" method="Post" action="scholarshipselection.asp">
<input type="hidden" name="StudentID"
value="<%=request.cookies("studentid")%>">
<input type="hidden" name="Password"
value="<%=request.cookies("password")%>">
</form>
<script type="text/javascript">
document.forms[0].submit()
</script>

An alternative (probably better) solution is to use xmlhttp to post the
data, eg
<%
url = "http://you.com/scholarshipselection.asp"
set xmlhttp = server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "POST", url, false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send "StudentID=" & request.cookies("studentid") & "&password="
&request.cookies("password")
Response.write xmlhttp.responseText
set xmlhttp = nothing
%>

--
Cheers,
Jon
Microsoft MVP - FP

JasonLFunk said:
The form action is just the name of the page. My Form looks like this:

<form name="hidden" method="Post" action="scholarshipselection.asp"><input
type="hidden" name="StudentID"> said:
I set the values of the hidden forms with Javascript from imformation from
a cookie. I want to use those two forms as my Database Critera Search
Results which uses the webbot. I want the page to think that the user
entered the two values and pushed the submit button when the page loads so
the data is automatically there. But I dont want a submit button or the
textbox. I added a line in my javascript like this
'document.hidden.submit()' and it got recursive I guess and kept reloading
itself over and over agian. Help Please
 
T

Thomas A. Rowe

Is the purpose of doing this to immediately display the user database record
on the specific page automatically each time thy hit the page?

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================


JasonLFunk said:
The form action is just the name of the page. My Form looks like this:

<form name="hidden" method="Post" action="scholarshipselection.asp"><input
type="hidden" name="StudentID"> said:
I set the values of the hidden forms with Javascript from imformation from
a cookie. I want to use those two forms as my Database Critera Search
Results which uses the webbot. I want the page to think that the user
entered the two values and pushed the submit button when the page loads so
the data is automatically there. But I dont want a submit button or the
textbox. I added a line in my javascript like this
'document.hidden.submit()' and it got recursive I guess and kept reloading
itself over and over agian. Help Please
 
T

Thomas A. Rowe

Ok, then a form is not needed, on scholarshipselection.asp do something
similar to the following:

<%
StudentID = Request.Cookies("StudentID")
Password = Request.Cookies("Password")

Dim DSN_Name
DSN_Name = Application("Name_ConnectionString")
set Connection = Server.CreateObject("ADODB.Connection")
Connection.Open DSN_Name

Set objRS = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM StudentTable Where StudentID = '" & StudentID & "'
and Password = '" & Password & "' "
objRS.Open strSQL, DSN_Name
%>
<html>
<head>
content
</head>
<body>
page content and display of database content related to this student
</body>
</html>
<%
objRS.Close
Set objRS = Nothing

Connection.Close
Set Connection = Nothing
%>

Notes:
The above is based on using a System DSN.
The Application(...) is from the Global.asa file.
The strSQL statement needs to be on a single line.
The StudentID field is a assumed to be a text field, an not a number or
autonumber field.

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
J

Jon Spivey

Thomas,
he's using the database results wizard - not hand coding. Agreed he would
be better off writing his own but if he doesn't want to the xmlhttp method
I posted up earlier is probably the best way to pass things like cookies to
the wizard. Create the results page the way you want then post your cookie
data to it with xmlhttp and response.write the result.

I seem to remember there's also an edit you can make to one of the FP files,
if Steven Travis is around he'd know.
 
T

Thomas A. Rowe

Ok.

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
J

Jon Spivey

If you do go the hand coding route there's no need to open a connection and
a recordset - very inefficient. It looks like you're opening a connection
then not doing anything with it.
Also using a DSN is probably not good
a/ DSNs are measurably slower than oledb
b/ DSNs have been deprecated - they may or may not be supported in future
releases but they certainly won't be upgraded/improved. At some stage you'll
have to migrate from DSNs so if you're writing new code it might as well be
now.

Unless you need access to recordset properties this would probably be
quickest
<%
set oConn = server.createobject("adodb.connection")
oConn.open(oledb connection string)
set oRs = oConn.execute("select field1, field2 from table")
' display data
%>

In most cases we'd want to retrieve more than 1 row so using getrows to
stuff the data into an array and then closing the connection before
displaying the data would be best.
 
T

Thomas A. Rowe

Jon,

Where is it written that a DSN connection has been or will be "Depreciated"
?

As for the speed issue, see:
http://www.adopenstatic.com/experiments/ConnStringSpeed.asp

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
T

Thomas A. Rowe

Jon,

Since Windows 2003 Standard still provides support, so there is no need to
stop using a System DSN.

The advantage of my using a System DSN, other than the fact that it works
and works well, is:

1. I don't have to worry about the physical location of the database between
my local Windows 2003 Server and the remote web host server, since the
database is always stored outside of the web root.

2. Very easy to access the database via the System DSN from any subweb
within a specific hosting account.

3. Added security, no direct path to the database is stored within any file
within in a web site.

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, Forums, WebCircle,
MS KB Quick Links, etc.
==============================================
 
B

Bilal

hi all

I am facing a little problem. I have a form with a dropdownlist control. I have a button and when i click the form posts back
The problem is that in the on button click event i'm calling this metho
 
K

Kevin Spencer

Did you declare the "ddlColors" field in your Class definition?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Bilal said:
hi all,

I am facing a little problem. I have a form with a dropdownlist control. I
have a button and when i click the form posts back.
The problem is that in the on button click event i'm calling this method
value. It gives me this exception:
 
Top