|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Arrange sequential selections into ranges how to???
Author: Pascal Peters
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32610#163686
The hidden field doesn't need a value and can't be in the select. The
reason that you are not seeing the correct value in the actionpage is
that you don't call the function correctly in the onsubmit or that there
is an error in the function. Maybe a wrong case somewhere. JS is case
sensitive. I've sent you a sample form and action page that worked for
me off list.
Pascal
----- Excess quoted text cut - see Original Post for more -----
Author: Nathan R. Jessop
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32610#163672
I was able to get the listing to display by putting the hidden field outside of
the loop. For testing purposes I added a <cfdump var="#form#"> on my action
page to see whats
getting passed.
For example.
If I select the below pages:
1,2,3,4,5,6,7,8,9,15,16,17,18,19,25
When I submit the form I get the same output.
1,2,3,4,5,6,7,8,9,15,16,17,18,19,25
What I want to appear is this:
1-9,15-19,25
----- Excess quoted text cut - see Original Post for more -----
Author: Nathan R. Jessop
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32610#163669
Add a hidden field like this? It only displays the first folio.
Seq: 1 Folio: 2201
and then lists all the other pages outside of the <select>
<select name="filelistselect" size="15" multiple class="dirlinks">
<cfloop INDEX="i" FROM="1" TO="#ArrayLen(arPages)#">
<cfset sVal = Trim(ListFirst(arPages[i], ">"))>
<cfset sDisp = Trim(ListLast(arPages[i], ">"))>
<cfset sValNoComma = NumberFormat(sVal, "9999999999")>
<cfset sVal = NumberFormat(sVal)>
<option value="#sValNoComma#">Seq: #sValNoComma# Folio:
#sDisp##spacer1#</option>
<input type="hidden" name="filelist">
</cfloop>
</select>
----- Excess quoted text cut - see Original Post for more -----
Author: Pascal Peters
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32610#163661
Rename your select "filelistselect",
create a hidden field named "filelist"
and call this JS function in the onsubmit of the form:
function makeList(thisform){
var opts = thisform.filelistselect.options,
val="",
i=0;
for(;i<opts.length;i++){
if(opts[i].selected){
if(i==0 || !opts[i-1].selected){
val += ((val.length>0)?",":"") +
opts[i].value;
}
else if(i==opts.length-1 ||
!opts[i+1].selected){
val += "-" + opts[i].value;
}
}
}
thisform.filelist.value = val;
thisform.filelistselect.disabled = true;
}
<form ... onsubmit="makeList(this)">
Pascal
----- Excess quoted text cut - see Original Post for more -----
Author: Nathan R. Jessop
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32610#163652
>Do you need to pass it like this or can you transform the list on the
>server to make the ranges?
I need to pass it like 1-16,23-25,30,33,40-42,46-48 to the server.
Is the list always in numerical order?
Yes it is.
----- Excess quoted text cut - see Original Post for more -----
Author: Pascal Peters
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32610#163651
Do you need to pass it like this or can you transform the list on the
server to make the ranges? Is the list always in numerical order?
----- Excess quoted text cut - see Original Post for more -----
Author: Nathan R. Jessop
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:32610#163650
Hi,
I'm reading in an external file and then passing the results to my action page by
selecting all or individual selections.
This is what the listing would like from the file I'm reading in (which is
generated by a another program).
001>folio: 2201 . . . 274.00 points free
002>folio: 2251 . . . 021.00 points free
003>folio: 2252 . . . 001.00 points free
004>folio: 2253 . . . 011.00 points free
005>folio: 2254 . . . 001.00 points free
006>folio: 2255 . . . 001.00 points free
007>folio: 2256 . . . 213.00 points free
008>folio: 2301 . . . 412.00 points free
009>folio: 2305 . . . 202.00 points free
010>folio: 2311 . . . 009.00 points free
011>folio: 2312 . . . 003.00 points free
012>folio: 2313 . . . 000.50 points free
013>folio: 2314 . . . 006.50 points free
014>folio: 2315 . . . 321.50 points free
015>folio: 2317 . . . 008.00 points free
016>folio: 2318 . . . 006.50 points free
017>folio: 2319 . . . 230.50 points free
018>folio: 2325 . . . 000.00 points free
019>folio: 2326 . . . 001.00 points free
020>folio: 2327 . . . 202.50 points free
021>folio: 2335 . . . 007.00 points free
022>folio: 2336 . . . 012.00 points free
023>folio: 2337 . . . 001.50 points free
024>folio: 2338 . . . 010.00 points free
025>folio: 2339 . . . 004.00 points free
026>folio: 2340 . . . 012.50 points free
027>folio: 2341 . . . 001.50 points free
028>folio: 2342 . . . 007.50 points free
029>folio: 2343 . . . 001.50 points free
030>folio: 2344 . . . 007.50 points free
031>folio: 2345 . . . 022.00 points free
I then loop through the file and display the results in a <select>.
It would display something like this:
Seq: 1 Folio: 2201
Seq: 2 Folio: 2202
Seq: 3 Folio: 2203
Seq: 4 Folio: 2204
Seq: 5 Folio: 2205
Seq: 6 Folio: 2206
Seq: 7 Folio: 2207
...and so on...
From here the user can select all the pages or individual selections using the
Shift or Ctrl keys. The results are passed to my action page as a comma
delimiited list (variable) and
fed into the program. At times the user selsection can be VERY large and the
program barfs because it can't handle such a large string.
So this is my question. How can I arrange sequential selections into ranges.
Meaning is a user selects the first 50 pages. Currently when the selection gets
passed to my action
page the results would be:
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
How can I make the above get passed as:
1-50?
and if the selection happended to be:
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,23,24,25,30,33,40,41,42,46,47,48
How can I make the above get passed as this:
1-16,23-25,30,33,40-42,46-48
The below code generate the listing like:
Seq: 1 Folio: 2201
Seq: 2 Folio: 2202
Seq: 3 Folio: 2203
Seq: 4 Folio: 2204
Seq: 5 Folio: 2205
Seq: 6 Folio: 2206
Seq: 7 Folio: 2207
...and so on...
<select name="filelist" size="15" multiple class="dirlinks">
<cfloop INDEX="i" FROM="1" TO="#ArrayLen(arPages)#">
<cfset sVal = Trim(ListFirst(arPages[i], ">"))>
<cfset sDisp = Trim(ListLast(arPages[i], ">"))>
<cfset sValNoComma = NumberFormat(sVal, "9999999999")>
<cfset sVal = NumberFormat(sVal)>
<option value="#sValNoComma#">Seq:
#sValNoComma# Folio: #sDisp##spacer1#</option>
</cfloop>
</select>
---------------------------------------------------
Colonel Nathan R. Jessop
Commanding Officer
Marine Ground Forces
Guatanamo Bay, Cuba
---------------------------------------------------
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||