asp function

L

led

it is possible to submit a form based on result of a asp function??

this is the function:
<%
Function fp1_onsubmit

Dim myConnString
Dim myConnection

Dim rs

myConnString = Application("basededados1_ConnectionString")


Set myConnection = Server.CreateObject("ADODB.Connection")


myConnection.Open myConnString

set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select precos.* from precos where cod_casa=" & request("cod_casa")
& " And livre= false", myConnString

do while not rs.eof
for i = rs.fields.item("inicio") to rs.fields.item("fim")

if i= request("inicio") then
fp1_onsubmit=false
end if

next
rs.movenext

loop

myConnection.Close
Set myConnection = Nothing
end Function
%>

but when i submit the form the expected doesn't happen
where is the problem?
 
D

David Berry

Why would you want to do it this way? Why not make a page called, ex:
FormResults.asp that contains the code that's in your fucntion and then set
the Action of the form to FormResults.asp Ex:

<form method = "post" action = "FormResults.asp">

........ your fields

</form>

then FormResults.asp would be:

<%
Dim myConnString
Dim myConnection
Dim rs

myConnString = Application("basededados1_ConnectionString")
Set myConnection = Server.CreateObject("ADODB.Connection")
myConnection.Open myConnString

set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select precos.* from precos where cod_casa=" &
request.form("cod_casa")
& " And livre= false", myConnString

do while not rs.eof
for i = rs.fields.item("inicio") to rs.fields.item("fim")
next
rs.movenext

loop

myConnection.Close
Set myConnection = Nothing

Response.Redirect ("ThePageYouWantThemToSee.asp")


%>
 
L

led

u did't answer my question. can i call it or not

David Berry said:
Why would you want to do it this way? Why not make a page called, ex:
FormResults.asp that contains the code that's in your fucntion and then
set the Action of the form to FormResults.asp Ex:

<form method = "post" action = "FormResults.asp">

....... your fields

</form>

then FormResults.asp would be:

<%
Dim myConnString
Dim myConnection
Dim rs

myConnString = Application("basededados1_ConnectionString")
Set myConnection = Server.CreateObject("ADODB.Connection")
myConnection.Open myConnString

set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select precos.* from precos where cod_casa=" &
request.form("cod_casa")
& " And livre= false", myConnString

do while not rs.eof
for i = rs.fields.item("inicio") to rs.fields.item("fim")
next
rs.movenext

loop

myConnection.Close
Set myConnection = Nothing

Response.Redirect ("ThePageYouWantThemToSee.asp")


%>
 

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

Similar Threads


Top