Advertisement

09.10.2008 at 08:00AM PDT, ID: 23719453 | Points: 500
[x]
Attachment Details

Trying to submit values via form.

Asked by flfmmqp in JavaScript, Active Server Pages (ASP)

I'm running into a problem with trying to pass values to another form.  I am using the onSubmit="return submitForm()" to keep the values when my ddlDivision goes to update my ddlMarket dropdown list.  So since I am using this I need another way to get to the process form that checks to make sure the values are valid or not and if so submits the information to the database.  However, when I use the window.location = "simpleformprocess.asp"; it does not keep my values.  

Below I am attaching the code for both pages.  I have simplified the forms greatly in hopes it will make it easier for someone to help me.  Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
<-- //////////////////  Form Page /////// -->
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
 
<%
dim strDataPath, strConnectString, objConnection
dim strDivision, strMarket, strCity, objRS, strSelected, strSQL
strDivision = Request.Form("ddlDivision")
strMarket = Request.Form("ddlMarket")
'set connection strings for entire application
strDataPath = server.MapPath("/Databases/CompEvents.mdb")
strConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;"_
            + " Data Source= " & strDataPath & ";"_
            + " Mode=Share Deny None;User Id=admin;PASSWORD=;"
 
if not IsObject("ojbConnection") then
    set objConnection=Server.CreateObject("ADODB.Connection")
    objConnection.ConnectionTimeout = 15
    objConnection.CommandTimeout = 10
    objConnection.Mode = 3 'adModeReadWrite 
    if objConnection.state = 0 then
        objConnection.Open strConnectString
    end if
end if
 
sub makeDivision()
 
    if not isObject("objRS") then
        set objRS=Server.CreateObject("ADODB.RecordSet")
    end if
    if objRS.state <> 0 then
        objRS.close
    end if
    //strSQL = "SELECT Dmas.Division, Dmas.DMAID, Dmas.DMANAME FROM Dmas GROUP BY Dmas.Division, Dmas.DMAID, Dmas.DMANAME HAVING (((Dmas.Division)<>'MCF')) ORDER BY Dmas.Division;"
    strSQL = "SELECT DMAS.Division FROM DMAS GROUP BY DMAS.Division;"
    objRS.Open strSQL,objConnection,3,3
    Response.Write("<option></option>" & VBCRLF )
    do while not objRS.EOF
        if objRS("Division") = strDivision then
            strSelected = " Selected "
        else
            strSelected = ""
        end if
        Response.Write("<option" & strSelected & ">" &_
                 objRS("Division") & "</option>" & VBCRLF )
        objRS.MoveNext
    loop
    objRS.Close
    set objRS=Nothing
end sub
 
 
 
 
sub makeMarket()
    if strDivision <> "" then
        if not isObject("objRS") then
            set objRS=Server.CreateObject("ADODB.RecordSet")
        end if
        if objRS.state <> 0 then
            objRS.close
        end if
    //strSQL = "SELECT Dmas.Division, Dmas.DMAID, Dmas.DMANAME FROM Dmas GROUP BY Dmas.Division, Dmas.DMAID, Dmas.DMANAME HAVING (((Dmas.Division)<>'" & strDivision & "')) ORDER BY Dmas.DMANAME;"
    strSQL = "SELECT DMAS.DMANAME FROM DMAS WHERE (((DMAS.Division)='" & strDivision & "')) ORDER BY DMAS.DMANAME;"
 
        objRS.Open strSQL,objConnection,3,3
        if objRS.eof then
            Response.Write("<option>No Markets Found</option>")
        else
            Response.Write("<option>Select Market Now</option>" & VBCRLF )
            do while not objRS.EOF
                if objRS("DMANAME") = strMarket then
                    strSelected = " Selected "
                else
                    strSelected = ""
                end if
                Response.Write("<option" & strSelected & ">" &_
                         objRS("DMANAME") & "</option>" & VBCRLF )
                objRS.MoveNext
            loop
        end if
        objRS.Close
        set objRS=Nothing
    else
        Response.Write("<option>Select a Division First</option>")
    end if
end sub
%>
 
 
 
<SCRIPT LANGUAGE=javascript>
 
<!--
 
function submitDivision(){
    var objForm = document.forms[0];
    objForm.elements['ddlMarket'].selectedIndex=0;    
    objForm.submit();
}
 
function submitMarket(){
    var objForm = document.forms[0];
    objForm.submit();
}
 
function redirectToProccessPage(){
    //alert(" found redirectToProccessPage");
     var objForm = document.forms[0];
     objForm.submit();
    window.location = "simpleformprocess.asp";
}
 
 
//-->
</SCRIPT>
</head>
<body>
 
  <FORM METHOD="post" onSubmit="return submitForm()" name="CE_EntryInfo" ENCTYPE="application/x-www-form-urlencoded">
<!--<FORM METHOD="post" ACTION="simpleformprocess.asp" name="CE_EntryInfo" ENCTYPE="application/x-www-form-urlencoded">
--> 
 
     C:\Inetpub\wwwroot\CE\Delete Me\simpleform.asp<br />
     <br />
     Username:<br />
    <INPUT style="WIDTH: 164px; BACKGROUND-COLOR: yellow" id="username" tabIndex=0 type=text value='<%=Request("username")%>' name="username" /><br />
    <br />
    
    Division:<br />
    <SELECT style="WIDTH: 170px; BACKGROUND-COLOR: yellow" onchange="submitDivision()" name="ddlDivision"> <%call makeDivision%></SELECT>
    <br />
    <br />
    Market:<br />
    <SELECT name="ddlMarket"> 
        <%call makeMarket%>
    </SELECT>
    <br />
    <br />
 
    
<!--    <INPUT style="WIDTH: 164px; BACKGROUND-COLOR: yellow" id="Text1" tabIndex=0 type=text name="username" />
--> 
    <input id="Submit1" type="submit" value="Submit via Form" />   <INPUT id="btnSubmit" onclick="redirectToProccessPage()" type=button value="Submit via redirectToProccessPage()" style="width: 232px" />
 </FORM>    
</body>
</html>
 
<-- //////////////////  Form Process Page /////// -->
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
</head>
<body>
<% dim username, usertitle, userid, dma, action, completionyear
'Get values from the form.
    username = request.form("username")  
    dma = request.form("dma")
    division = Request.form("division")
 
    response.write "<br><br><b>UserName:&nbsp &nbsp</b> " & userName & "<br>" & vbNewLine
    response.write "<br><br><b>DMA:&nbsp &nbsp</b> " & dma & "<br>" & vbNewLine
    response.write "<br><br><b>Division:&nbsp &nbsp</b> " & division & "<br>" & vbNewLine
%>
</body>
</html>
[+][-]09.10.2008 at 08:04AM PDT, ID: 22439085

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.10.2008 at 08:17AM PDT, ID: 22439226

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.10.2008 at 08:29AM PDT, ID: 22439359

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.10.2008 at 09:05AM PDT, ID: 22439850

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.10.2008 at 09:43AM PDT, ID: 22440249

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.10.2008 at 10:02AM PDT, ID: 22440440

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.10.2008 at 11:03AM PDT, ID: 22441148

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.10.2008 at 11:26AM PDT, ID: 22441357

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.10.2008 at 12:33PM PDT, ID: 22442066

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.11.2008 at 07:45AM PDT, ID: 22450433

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.22.2008 at 06:42AM PDT, ID: 22776461

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628