Advertisement

09.04.2008 at 10:12AM PDT, ID: 23703455 | Points: 500
[x]
Attachment Details

Saving values during submit Part 2

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

I have a dropdown box that is connected to a text box.  Depending on what happens with the dropdown box it either enables or disables it.  If it disables it then it clears the box.  The problem is that I have another dropdown box that is used to filter another dropdown box doing a form submit.  Can anyone help me find a simple way to keep the value in the txtIncrementalGSF box?

Thanks,

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:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
<%@ Language = VBScript %>
 
<%Option Explicit%>
 
<%Response.Buffer = True%>
 
<HTML>
 
<HEAD>
 
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
 
<TITLE></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 AllowNumericOnly()
      {
            Expression = '0123456789';
            var ch = String.fromCharCode(window.event.keyCode);
            ch = ch.toLowerCase();
            var a = Expression.indexOf(ch);
            if (a == -1) 
                  window.event.keyCode = 0;
      } 
 
    function enableActionStartDate() {
    strActionStartDate = document.CE_EntryInfo.ddlAction.value;
    if(strActionStartDate=="0") 
      {
        //document.CE_EntryInfo.txtStartDate.disabled=true;
        
         //document.CE_EntryInfo.imgSmallCalendar.disabled = true;
         //document.CE_EntryInfo.txtStartDate.value = "";
         document.CE_EntryInfo.txtIncrementalGSF.disabled = true;
         document.CE_EntryInfo.txtIncrementalGSF.value = "";
 
          //if(enabled)show_calendar("CE_EntryInfo.txtStartDate");
          //return;
     }
    else 
      { 
          //document.CE_EntryInfo.imgSmallCalendar.disabled = false;
          document.CE_EntryInfo.txtIncrementalGSF.disabled = true;
          document.CE_EntryInfo.txtIncrementalGSF.value = "";
         //document.CE_EntryInfo.txtStartDate.value = "";
     }
 
    if(strActionStartDate=="Downsizing") 
     {
         document.CE_EntryInfo.txtIncrementalGSF.disabled = false;
         document.CE_EntryInfo.txtIncrementalGSF.value = "";
     }    
    
    if(strActionStartDate=="Expanding") 
     {
         document.CE_EntryInfo.txtIncrementalGSF.disabled = false;
         document.CE_EntryInfo.txtIncrementalGSF.value = "";
     }    
    }  
 
//-->
</SCRIPT>
</HEAD>
<BODY onLoad="window.moveTo(0,0);window.resizeTo(400,400);">
 
<FORM action="" method=POST id="CE_EntryInfo" name="CE_EntryInfo" onSubmit="return submitForm()">
<SELECT name="ddlDivision" onChange="submitDivision()">
    <%call makeDivision%>
</SELECT><br>
 
<SELECT name="ddlMarket">
    <%call makeMarket%>
</SELECT>
 
                     <select id="ddlAction" style="width: 170px; background-color: yellow;" name="action" onchange="enableActionStartDate()" tabindex="9" language="javascript" onclick="return ddlAction_onclick()">
                        <option value="0">-- Select Action --</option>
                         <%                 
	                        Set objRS = Server.CreateObject("ADODB.Recordset")
	                        objRS.Open "SELECT CE_ActionType.ID, CE_ActionType.ActionType FROM CE_ActionType;", "dsn=CompEvents"	 
    			                        'Loop through the recordset adding each Center Type to the combo box
			                        Do While Not objRS.EOF
 
								  	If objRS("ActionType") = Request("action") Then
                        %>        
                        <option selected="selected" value="<%=objRS("ActionType")%>"> <%=objRS("ActionType")%></option>
                        <%
								  	Else
                        %>        
                        <option value="<%=objRS("ActionType")%>"> <%=objRS("ActionType")%></option>
                        <%
				    					End If
				                        objRS.MoveNext
			                        Loop
 
			                        'Close and dereference database objects
 
 
                         %>
                    </select>
 
 
                      <input id="txtIncrementalGSF"  value='<%=Request("incrementalgsf")%>' type="text" style="width: 164px" name="incrementalgsf" onkeypress="AllowNumericOnly();" maxlength="4" tabindex="8" disabled="disabled"/></td>
 
 
    <input id="Submit1" type="submit" value="submit" />
</FORM>
</BODY>
<%
objConnection.Close
set objConnection = Nothing
%>
</HTML>
[+][-]09.04.2008 at 10:23AM PDT, ID: 22390102

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 10:27AM PDT, ID: 22390139

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.04.2008 at 10:28AM PDT, ID: 22390159

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628