PDA

View Full Version : passing all values for display


ooiooipig
04-03-2003, 01:14 AM
Hi all, anyone can advise me on how to pass information from the action page to the display page??

flow chart:

1st page to let user enter the fields.
information is then pass to the action page upon submission.

action page is used to input the values into the database, generation of the reference number is also in the action page.

when the entry is successfully completed, there will be a prompt to inform the user that the request is successfully done. a button will let user decide if he wants to view the form( which contain the informations that he entered previously in the 1st page ).

all the information are then passed into the display page (aka form) for user to view or print.

how can i pass the information from the 1st page and the reference number from the action page to the display information page.

please help! :(

miranda
04-03-2003, 01:46 AM
use hidden form fields on the action page with the values set to the information derived from the 1st page.
As for the reference number, you will need to make a call to the database to get the reference numer. then fill that value into another hidden form field

ooiooipig
04-03-2003, 01:53 AM
in the action page, i only have sql statements. where do i store the hidden fields? and near the last part of the code, there's the buttons. i'm not sure if this is the correct way to put in the buttons. please help! thanks...


this is the code of my action page:
____________________________________________________
____________________________________________________

<!--#include file="../include/dbconn.asp"-->
<html>
<body bgcolor="#FFCCCC">

<%
'sql1 = "select ReqMonth from ReqNoRef where ReqMonth = " (Month(Now))
sql1 = "select ReqYear, LastReqNo from ReqNoRef where ReqMonth = (Month(getDate()))"
set rs=MSCS.execute(sql1)

if not rs.eof then
'Reset Year
if rs("ReqYear") <> Year(now()) then
LastNo = 1
else
LastNo = rs("LastReqNo") + 1
end if
'Format Request Number
strLastNo = right("000" & cstr(LastNo),4)
'Format Month
strMonth = right("0" & cstr(month(date())),2)
'Format Request No
ReqNo = "RQ" & cstr(year(date())) & strMonth & strLastNo

'Begin Transactions
MSCS.Errors.Clear
MSCS.BeginTrans

'Insert Request
sql="INSERT INTO Requests (ReqNo,ReqType,AppnId,reqTitle,ReqDt,DesiredDt,Reqtr,ReqtrEmail,ContactNo,Dept,RC,Priority,funcReq,F reqVol,Savings,Revenue,Benefit,Tester,TesterContact,ApprovOfficer,ApprovEmail)"
sql=sql & " VALUES "
sql=sql & "('" & ReqNo & "',"
sql=sql & "'" & Request.Form("vReqType") & "',"
sql=sql & "'" & Request.Form("vAppnId") & "',"
sql=sql & "'" & Request.Form("vreqTitle") & "',"
sql=sql & "'" & date() & "',"
sql=sql & "'" & Request.Form("vDesiredDt") & "',"
sql=sql & "'" & Request.Form("vReqtr") & "',"
sql=sql & "'" & Request.Form("vReqtrEmail") & "',"
sql=sql & "'" & Request.Form("vContactNo") & "',"
sql=sql & "'" & Request.Form("vDept") & "',"
sql=sql & "'" & Request.Form("vRC") & "',"
sql=sql & "'" & Request.Form("vPriority") & "',"
sql=sql & "'" & Request.Form("vfuncReq") & "',"
sql=sql & "'" & Request.Form("vFreqVol") & "',"
sql=sql & "'" & Request.Form("vSavings") & "',"
sql=sql & "'" & Request.Form("vRevenue") & "',"
sql=sql & "'" & Request.Form("vBenefit") & "',"
sql=sql & "'" & Request.Form("vTester") & "',"
sql=sql & "'" & Request.Form("vTesterContact") & "',"
sql=sql & "'" & Request.Form("vApprovOfficer") & "',"
sql=sql & "'" & Request.Form("vApprovEmail") & "')"
'Response.Write "Update command" & sql
'Response.End

MSCS.execute(sql)

'Update Last Request No into ReqNoRef
if rs("ReqYear") <> Year(now()) then
sql = "update ReqNoRef set ReqYear='" & Year(now())& "', LastReqNo = LastNo where ReqMonth = (Month(getDate()))"
else
sql = "update ReqNoRef set LastReqNo='" & LastNo & "' where ReqMonth = (Month(getDate()))"
end if
' Response.Write "Update command" & sql
' Response.End
MSCS.execute(sql)

if MSCS.Errors.Count = 0 then
MSCS.CommitTrans
Response.Write "New IS Request successfully saved <BR>"%>
<form method="post" action="display_form.asp" target="_blank">
<input type="submit" name="submit" value="View Form">
</form>
<form method="post" action="../rightframe.asp">
<input type="submit" name="submit" value="Close">
</form>
<%else
MSCS.RollbackTrans
Response.Write DBConn.Errors.Number
Response.Write "Warning: saving new IS request failed"
end if
end if

rs.close
set rs=nothing

'redirecturl = "request_type.asp"
'Response.Redirect redirecturl
%>
</body>
</html>
<!--#include file="../include/dbclose.asp"-->

____________________________________________________
____________________________________________________

miranda
04-03-2003, 02:29 AM
the easiest way is to assign a variable name for each field
like so

Dim vReqType, vAppnId, vreqTitle, vDesiredDt
vReqType = Request.Form("vReqType")
vAppnId = Request.Form("vAppnId")
vreqTitle = Request.Form("vreqTitle")
vDesiredDt = Request.Form("vDesiredDt")

and so on

Then just make the form fields on the page
like so
<form method=post action=asppage.asp>
<input type="hidden" name="vReqType" value="<%=vReqType%>">
and so on...

Now you can either send them back to the 1st page and using asp to get the refering page (action page) decide if you fill in the values
like so
on 1st page
<%
Dim Refpage, viewInfo
RefPage = Request.ServerVariables("http_referer")
If RefPage = (your action page url) Then
viewInfo = True
Else
viewInfo = False
End If
Dim vReqType, vAppnId, vreqTitle, vDesiredDt
vReqType = Request.Form("vReqType")
vAppnId = Request.Form("vAppnId")
vreqTitle = Request.Form("vreqTitle")
vDesiredDt = Request.Form("vDesiredDt")
%>
<input type="text" name="vReqType" <%If viewInfo = True Then Response.write "value="" & vReqType & """"%>>

and so on for each item

OR just duplicate the 1st page and add the value for each field then send them to that page.

Personally i would go with the first option

ooiooipig
04-03-2003, 02:52 AM
how can i place two buttons in a form??
as far as i know, once there's a button

<input type="submit" name="submit" value="View Form">

it'll be posted to the file stated in the

<form method="post" action="display_form.asp" target="_blank">

however, how do i create another button beside the above stated button and direct it to the default page?? i think should use onclick="blah blah blah" but i'm not sure what the code in the " " is...

can anyone advise??

miranda
04-03-2003, 03:28 AM
do it the way you show with 2 different forms just put all the hidden form fields inside the one form or use javascript and write functions to handle the onClick event depending on what you want each button to do If you use one form and 2 buttons change one of them to be of type=button instead of submit and then include onClick="whatEver();"
for example
<input type="button" name="submit" value="View Form" onClick="submitForm();">
<input type="button" name="whatever" value="Whatever" onClick="whatEver();">
Client side javascript

function submitForm(){
document.form.the_forms_name_goes_here.submit();
}
function whatEver(){
//write a function to handle whatever you want done
}

ooiooipig
04-03-2003, 03:31 AM
i think i shall stick to the way i did it at first... thanks a million!! it's completed!! :thumbsup: