Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 23rd, 2004, 05:59 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to acdsky
Default Passing data between 2 forms

Hi

What I have got is 2 asp pages, the first contains 2 listboxes and a text box. The first listbox looks up data form a access DB and submits the form on the onChange= event and then displays the second listbox containing the relative data. On the second page are some listboxes ect with a submit button that sends a mail with the completed fileds.

Because the 1st page submits to itself I have opened it in an iFrame on the second page.

My problem is I dont know how to include the data on the first page when the second page is being submited.

Any sugestions would be appreciated.

Regards
Marnus

Such is Life!
 
Old January 23rd, 2004, 06:44 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can use some javascript to pass information to the "outer" page (i.e. the page on which the iframe lives). The javascript syntax would be just the same as with regular framesets.

I'd recommend agains using an iframe however unless you know the users will be using IE. iframes are an IE specific HTML control (to my knowledge at this point). You might be better off to use a separate page and after you select the second item just redirect with the selected items on the querystring.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old January 26th, 2004, 06:54 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to acdsky
Default

Hi

Ok, what I used to get the data is:

function MM_callJS(jsStr) { //v2.0
  //alert("asd")
var X;
X = parent.iname.document.form.id.value;
alert(X); }

This seems to work fine but I have still got 2 problems...
1. How do I get the value for X in a VB variable so that it can be included in the mail send code? (The mail send is VBS)

2. On the second listbox, which is populated from the DB, I am not able to return the selected value, it only returns a blank even though it is selected.

Any ideas or sugestions? Below is the code for the page in the iframe, the select box I am having trouble with is called "type" (I have created a txt box called "X" which I use for testing)

Thanks
Marnus


<body><BODY bgcolor="#CCCCCC"></body>
<%
Dim strSQL
Dim conn
Dim rstCallType, rstCallCat
Dim iRequestedID
' Some basic checking and cleaning of the input
iRequestedID = Trim(Request.QueryString("id"))
iRequestedID = Replace(iRequestedID, "'", "''")

If IsNumeric(iRequestedID) Then
    iRequestedID = CInt(iRequestedID)
Else
    iRequestedID = 0
End If
' The form links back to this same file passing back the id
%>
<form name="form" action="pop2.asp" method="get">
<%
value1 = request.form("Type")
' Create ADO data connection object
Set conn = Server.CreateObject("ADODB.Connection")

'Open data connection - Use this line to use Access
conn.Open "DBQ=" & Server.MapPath("DB_CallCat.mdb") & ";" & "Driver={Microsoft Access Driver (*.mdb)};", "admin", ""

' Open data connection - Our SQL Server code
'conn.Open "Provider=SQLOLEDB;Data Source=10.2.1.214;" _
    '& "Initial Catalog=CallCats;Connect Timeout=15;" _
    '& "Network Library=dbmssocn;", "CallCats", "password"

' Build our query for select box 1
strSQL = "SELECT * FROM CallCat ORDER BY Call_Cat;"

' Create and open recordset object using existing connection
Set rstCallType = Server.CreateObject("ADODB.Recordset")
rstCallType.Open strSQL, conn, adOpenForwardOnly, adLockOptimistic, adCmdText

' Build our drop down box of salesmen names
If Not rstCallType.EOF Then
    rstCallType.MoveFirst
    %>
    <table width="80" border="0">
    <tr>
    <td>
    <b>Call Category:</b>
    </td>
    <td>
    <select name="id" onChange="javascript:form.submit()">
        <option></option>
        <% ' Loop through names
        Do While Not rstCallType.EOF
            Response.Write "<option value="""
            Response.Write rstCallType.Fields("id")
            Response.Write """"
            If rstCallType.Fields("id") = CInt(iRequestedID) Then
                Response.Write "selected=""true"""
            End If
            Response.Write ">"
            'Response.Write Trim(rstCallType.Fields("first_name"))
            'Response.Write " "
            Response.Write Trim(rstCallType.Fields("Call_Cat"))
            Response.Write "</option>" & vbCrLf

            ' Move to next record
            rstCallType.MoveNext
        Loop
        %>
    </select>
    </td>
    </tr>

    <%
End If

' Close ADO objects we're finished with and free DB variables
rstCallType.Close
Set rstCallType = Nothing

' If a request for a specific id comes in, then build second select box
If iRequestedID <> 0 Then
    strSQL = "SELECT * FROM CallType WHERE CallCatId = " _
        & iRequestedID & " ORDER BY CallType"

    Set rstCallCat = Server.CreateObject("ADODB.Recordset")
    rstCallCat.Open strSQL, conn, adOpenForwardOnly, adLockOptimistic, adCmdText

    ' Build our drop down box of the salesmen's sales
    If Not rstCallCat.EOF Then
        rstCallCat.MoveFirst
        %>
        <tr>
        <td>
        <b>Call Type:</b>
        </td>
        <td>

        <select name="type" onChange="this.form.X.value = this[this.selectedIndex].value;">
            <option></option>
            <% ' Loop through names
            Do While Not rstCallCat.EOF
                Response.Write "<option>"
                Response.Write Trim(rstCallCat.Fields("CallType"))
                Response.Write "</option>" & vbCrLf
                ' Move to next record
                rstCallCat.MoveNext
            Loop
            %>
        </select>
        </td>
        </tr>
        <%
    End If
    ' Close ADO objects we're finished with and free DB variables
    rstCallCat.Close
    Set rstCallCat = Nothing
End If

' Close ADO objects we're finished with and free DB variables
conn.Close
Set conn = Nothing
%>
<tr>
<td>
<b>Priority:</b>
</td>
<td>
<select name="priority" id="priority">
                <option>Please select from list</option>
                <option value="1 - Critical">1 - Critical</option>
                <option value="2 - Severe">2 - Severe</option>
                <option value="3 - Medium">3 - Medium</option>
                <option value="4 - Low">4 - Low</option>
                </select>
</td>
</tr>
<tr>
<td>
<b>Transaction Code:</b>
</td>
<td>
<input name="transcode" type="text" id="transcode">
</td>
</tr>
<tr>
<td>
<b>Company Code:</b>
</td>
<td>
<input name="compcode" type="text" id="compcode" size="6" maxlength="4">
<input name="X" type="text">
</td>
</tr>
</Table>
</form>



Such is Life!





Similar Threads
Thread Thread Starter Forum Replies Last Post
passing data on multiple forms dzisaacs C# 2 December 6th, 2007 02:03 PM
Passing Parameters Between Two Forms sjf905 C# 2 January 13th, 2007 10:44 PM
Passing data between forms pactite Access 5 June 4th, 2005 03:02 PM
Passing data between forms rwalker VS.NET 2002/2003 6 February 17th, 2005 08:17 AM
Passing values between forms alok992 C# 1 April 28th, 2004 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.