I found some code from Mike Nimer's site for a slush box and I wanted to make some changes. Right now the overall functionality works but with some quirks. I was wondering if anybody had some insight into how to correct these issues. The issue I am having is that the primary author can be selected as a primary and also as a secondary author which should not be the case. On a side note the primary author is not necessary the user logged in so I can hard code the mysql query this way. I would like to cycle through the list and eliminate the selected primary author from the first select but then add it in if the primary box is changed. This would take care of another issue I have with a user using the cntl key and selecting many people in the primary box, which will allow the primary author to get selected. The second main issue is that people need to log back in to modify their reports which will populate the primary select field and the right select field accordingly. This creates a problem because the user can select a primary author that is in the right select box. Right now I have an onchange event that erases the right select box. I would like it the onchange event for the primary select box to loop through the right select box and remove the primary author. Right now I should have some code that should work but it doesn't at least for the second of my two problems. I was wondering if anybody knew what the syntax problem was in my actionscript code? I have been working this for a few days and would like any feedback given. Thank you for your time! Jeff D. Here is the code for the slush box custom tag........ <cfparam name="attributes.name" type="variableName"> <cfparam name="attributes.query" type="query"> <cfparam name="attributes.valuecol" type="string" default="id"> <cfparam name="attributes.displaycol" type="string" default="value"> <cfparam name="attributes.initials" type="string" default="value"> <cfparam name="attributes.primaryAuth" type="string" default="value"> <cfparam name="attributes.colwidth" type="numeric" default="200"> <cfparam name="attributes.size" type="numeric" default="10"> <cfparam name="attributes.selected" default=""> <cfparam name="attributes.label" default=""> <cfsavecontent variable="addScript"> <cfoutput> if(lb1.selectedIndices != undefined) { var r:Array = lb1.selectedIndices.sort(16|1); var x = 0; for( var i=0; i<r.length; i++ ) { if(lb1.value != primary.text || rmv == 1){ var rmv = 0; lb2.addItem(lb1.getItemAt(r[i] - x)); lb1.removeItemAt(r[i] - x); x++; } } } <!--- The code below will sort the box ---> if(sort == 1) { lb2.sortItemsBy("label","ASC"); var sort =0; } // reset left and right #attributes.name#_left.text = ''; #attributes.name#_right.text = ''; var t:Array = Array(); for(var i=0; i < #attributes.name#_select1.getLength();i++) { t.push(#attributes.name#_select1.getItemAt(i).data); } #attributes.name#_left.text = t.join(","); var t2:Array = Array(); for(var i=0; i < #attributes.name#_select2.getLength();i++) { t2.push(#attributes.name#_select2.getItemAt(i).data); } #attributes.name#_right.text = t2.join(","); </cfoutput> </cfsavecontent> <cfsavecontent variable="selectAll"> <cfoutput> var bah:Array = Array(); for(var i=0; i<#attributes.name#_select1.length; i++) bah[i] = i; #attributes.name#_select1.selectedIndices = bah; var bah:Array = Array(); for(var i=0; i<#attributes.name#_select2.length; i++) bah[i] = i; #attributes.name#_select2.selectedIndices = bah; </cfoutput> </cfsavecontent> <cfset leftvalue = ""> <cfset rightvalue = ""> <cfloop query="attributes.query"> <cfif not listFind(attributes.selected, attributes.query[attributes.valuecol][currentRow])> <cfset leftvalue = listAppend(leftValue, attributes.query[attributes.valuecol][currentRow])> <cfelse> <cfset rightvalue = listAppend(rightValue, attributes.query[attributes.valuecol][currentRow])> </cfif> </cfloop> <cfformgroup type="horizontal" visible="no" height="0"> <cfinput type="text" name="#attributes.name#_left" value="#leftValue#" width="150"> <cfinput type="text" name="#attributes.name#_right" value="#rightValue#" width="150"> <cfinput type="text" name="primary" width="200" label="primary Name" bind="{#attributes.primaryAuth#.selectedItem.data}"> </cfformgroup> <cfformgroup type="horizontal" label="#attributes.label#"> <!--- Code for the Left select box ---> <cfselect name="#attributes.name#_select1" width="#attributes.colwidth#" size="#attributes.size#" multiple="Yes" onChange="var lb1=#attributes.name#_select1;var lb2=#attributes.name#_select2;#addScript#" disabled="{#attributes.primaryAuth#.selectedIndex !=1}"> <cfoutput query="attributes.query"> <cfif not listFind(attributes.selected, attributes.query[attributes.valuecol][currentRow])> <option value="#attributes.query[attributes.valuecol][currentRow]#">#attributes.query[at tributes.displaycol][currentRow]#, #attributes.query[attributes.initials][currentRow]#</option> </cfif> </cfoutput> </cfselect> <!--- Code for the Right select box ---> <cfselect name="#attributes.name#_select2" width="#attributes.colwidth#" size="#attributes.size#" multiple="Yes" onChange="var lb1=#attributes.name#_select2;var lb2=#attributes.name#_select1;var sort=1;var rmv=1;#addScript#"> <cfif len(attributes.selected)> <cfoutput query="attributes.query"> <cfif listFind(attributes.selected, attributes.query[attributes.valuecol][currentRow])> <option value="#attributes.query[attributes.valuecol][currentRow]#">#attributes.query[at tributes.displaycol][currentRow]#, #attributes.query[attributes.initials][currentRow]#</option> </cfif> </cfoutput> </cfif> </cfselect> </cfformgroup> This code is one an actual page that calls the slush.cfm file........................................... <cfparam name="form.Authors_Right" default=""> <cfparam name="form.Authors_Left" default=""> <cfparam name="url.edit" default=""> <cfset GetActivity.ActivityID = 7659> <cfset url.edit = 0> <cfquery name="GetAuthors" datasource="WEARS"> SELECT AuthorID, UserName, AuthorLastName, AuthorInitials FROM tblAuthor WHERE ActAuthor = 1 ORDER BY AuthorLastName </cfquery> <cfquery name="GetAuthorID" datasource="WEARS"> SELECT AuthorID FROM tblAuthorActivity WHERE ActivityID = #GetActivity.ActivityID# ORDER BY AuthorActivityID </cfquery> <cfset AuthorArray = ArrayNew(1)> <cfloop query = "GetAuthorID"> <cfset temp = ArrayAppend(AuthorArray, "#AuthorID#")> </cfloop>
If anybody is interested here is how I did it........ -Jeff <cfformitem type="script"> function remove(){ var r:Array = Authors_select2.getLength(); var x = 0; for( var i=0; i<r; i++ ) { Authors_select2.selectedIndex = i; if(PrimaryAuthorID.selectedItem.data == Authors_select2.selectedItem.data){ <!--- alert('Primary Author ID: ' +PrimaryAuthorID.selectedItem.data+ '\t\t\t\t\t Index: ' +Authors_select2.selectedIndex+ '', 'Alert');---> Authors_select1.addItem(Authors_select2.getItemAt(Authors_select2.select edIndex)); Authors_select2.removeItemAt(Authors_select2.selectedIndex); x++; } } Authors_select1.sortItemsBy("label","ASC"); } </cfformitem>
Don't see what you're looking for? Try a search.
|