Instead of putting the script at the end of the document, wrap the code in a function and call the function from the BODY's onLoad attribute.
-- Mosh Teitelbaum evoch, LLC Tel: (301) 942-5378 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ > -----Original Message----- > From: Barney Boisvert [mailto:[EMAIL PROTECTED] > Sent: Friday, March 21, 2003 12:15 PM > To: CF-Talk > Subject: RE: <CF_CEO_Dynamic_Pull_Down_Menus> Client Management ??? > > > It's a browser limitation. When the back button is pressed, the > 'onchange' > handler of the first dropdown isn't fired, so the second dropdown doesn't > have any options to be automatically selected. You might try putting a > script at the bottom of the page (within the BODY tags, after the > dropdowns) > that checks to see if the first dropdown is selected, and if so, populate > the second. that might get it repopulated in time for IE to > select what was > selected when the form was submitted and the Back button pressed, althuogh > I'm not sure. Depends on when IE resets to the default, on page load, or > when generating the dropdown. > > HTH, > barneyb > > > -----Original Message----- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > > Sent: Friday, March 21, 2003 8:27 AM > > To: CF-Talk > > Subject: <CF_CEO_Dynamic_Pull_Down_Menus> Client Management ??? > > > > > > I've got a JavaScript that takes the selection from the first > > pull down menu > > and populates the second pull down menu based on the first. The > > Script works > > fine and give the result page it's suppose to after submitting > > the form. The > > problem is, when you hit the back button, the first pull down > > menu is still > > selected but the second dynamically populated pull down has gone > > blank. I've > > got a CEO that is not happy about this. He wants the selection > > to stay when > > the user hits the back button. Is this a browser state limitation? > > > > Here's some code. Any comments are appreciated!!! > > > > > > <SCRIPT LANGUAGE="JavaScript"> > > > > <!-- Begin > > new Array( > > <CFOUTPUT query="QUERYNAME_ONE"> > > new Array("#Part_Number1# - #prod_type#", "#Part_Number1#"), > > </CFOUTPUT> > > new Array("", "") > > ), > > new Array( > > <CFOUTPUT query="QUERYNAME_TWO"> > > new Array("#Part_Number1# - #prod_type#", "#Part_Number1#"), > > </CFOUTPUT> > > new Array("", "") > > ) > > ); > > function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, > > badPrompt, > > defaultItem) { > > var i, j; > > var prompt; > > // empty existing items > > for (i = selectCtrl.options.length; i >= 0; i--) { > > selectCtrl.options[i] = null; > > } > > prompt = (itemArray != null) ? goodPrompt : badPrompt; > > if (prompt == null) { > > j = 0; > > } > > else { > > selectCtrl.options[0] = new Option(prompt); > > j = 1; > > } > > if (itemArray != null) { > > // add new items > > for (i = 0; i < itemArray.length; i++) { > > selectCtrl.options[j] = new Option(itemArray[i][0]); > > if (itemArray[i][1] != null) { > > selectCtrl.options[j].value = itemArray[i][1]; > > } > > j++; > > } > > // select first item (prompt) for sub list > > selectCtrl.options[0].selected = true; > > } > > } > > // End --> > > </script> > > > > THE SELECT PART OF THE FORM > > > > <select name="man" size="1" onChange="fillSelectFromArray(this.form.pn, > > ((this.selectedIndex == -1) ? null : team[this.selectedIndex-1]));"> > > <option value="0" SELECTED>Choose > > One</option> > > <CFOUTPUT query="ViewSearch_MANUFACTURER"> > > <option value="#Vendor#">#Vendor#</option> > > </CFOUTPUT> > > </select> > > <font face="trebuchet ms, trebuchet, verdana, > > arial, helvetica" size="3"><b>Part Number:</b></font> > > <SELECT NAME="pn" SIZE="1"> > > <OPTION> > > </OPTION> > > <OPTION> > > </OPTION> > > <OPTION> > > </OPTION> > > <OPTION> > > </OPTION> > > <OPTION> > > </OPTION> > > </SELECT> > > > I don't know if this is a bug, undocumented feature or > correct behavior? > > > But has anybody run into this before? > > > > > > I have some code such as this in a CFC creating an array of queries. > > > > > > <!--- > > > ******************* > > > Pseudo code example > > > ******************* > > > ---> > > > > > > <cfset QueryAry = ArrayNew(1)> > > > > > > <!--- This query will return one record ---> > > > <cfquery name="First" datasource="DSN"> > > > SELECT Field1, Field2, Field3 > > > FROM Table1 > > > WHERE ID = #IDVar# > > > </cfquery> > > > <cfset QueryAry[1] = First> > > > > > > <!--- This query will return zero to many records ---> > > > <cfquery name="Second" datasource="DSN"> > > > SELECT Field4, Field5, Field6 > > > FROM Table2 > > > WHERE ID = #IDVar# > > > </cfquery> > > > <cfset QueryAry[2] = Second> > > > > > > <cfreturn QueryAry> > > > > > > Then when I try to output the query results stored in the > array returned > > > from the CFC. > > > > > > <cfoutput> > > > #IsQuery(QueryAry[1])# <!--- This returns True ---> > > > #IsQuery(QueryAry[2])# <!--- This returns True ---> > > > </cfoutput> > > > > > > <!--- Case 1: This does not work ---> > > > <cfoutput query="QueryAry[1]"> > > > #Field1# > > > #Field2# > > > #Field3# > > > </cfoutput> > > > > > > <cfoutput query="QueryAry[2]"> > > > #Field4# > > > #Field5# > > > #Field6# > > > </cfoutput> > > > <!--- End Case 1 ---> > > > > > > <!--- Case 2: This does not work ---> > > > <cfloop query="QueryAry[1]"> > > > #Field1# > > > #Field2# > > > #Field3# > > > </cfloop> > > > > > > <cfloop query="QueryAry[2]"> > > > #Field4# > > > #Field5# > > > #Field6# > > > </cfloop> > > > <!--- End Case 2 ---> > > > > > > <!--- Case 3: This does work ---> > > > <cfoutput> > > > #QueryAry[1]["Field1"][1]# > > > #QueryAry[1]["Field2"][1]# > > > #QueryAry[1]["Field3"][1]# > > > </cfoutput> > > > > > > <cfloop from="1" to="#QueryAry[2].RecordCount#" index="i"> > > > <cfoutput> > > > #QueryAry[2]["Field4"][i]# > > > #QueryAry[2]["Field5"][i]# > > > #QueryAry[2]["Field6"][i]# > > > </cfoutput> > > > </cfloop> > > > <!--- End Case 3 ---> > > > > > > <!--- *** End Pseudo Code Example *** ---> > > > > > > I would be interested in any comments on this behavior by > > others in the CF > > > community, as well as Macromedia types if they care too say something. > > > > > > -------------- > > > Ian Skinner > > > Web Programmer > > > BloodSource > > > Sacramento, CA > > > > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

