Skip to main content
July 23, 2007
Question

preventing entry duplication in string

  • July 23, 2007
  • 2 replies
  • 314 views
Hello, I have a page of checkboxes.
When each checkbox is clicked I want a unique value entered into a string. The string should build up as multiple checkboxes are clicked (the string wil then be submitted to coldfusion for a database search).
I set up the below, however the "+=" operator duplicates previous string entries. How can I overcome this duplication ?
...or perhaps I have gone about the wrong way to perform this ?
Thanks in advance for any help.

RELEVANT CODE SEGMENT:
var selections:String = "";
myCheckboxListener.click = function() {
if (checkbox1.selected) {
selections += "tanks";
}
if (checkbox2.selected) {
selections += "aircraft";
}
}

submitbutton.onRelease = function (){
trace (selections);
}
This topic has been closed for replies.

2 replies

kglad
Community Expert
Community Expert
July 23, 2007
oops, i just realized your probably calling myCheckboxListener every time a checkbox is clicked.

don't do that. make myCheckboxListener a function that's called in the first line of submitbutton.onRelease and nowhere else.
kglad
Community Expert
Community Expert
July 23, 2007
what is it that you want to submit to cf if both checkboxes are selected?
July 23, 2007
thank you kindly for helping.

My SWF search page has 30 checkboxes representing photo categories.

I want to submit a selection of photo category keywords to coldfusion that will be used to dynamically generate a photo gallery based on the users checkbox selections.

I thought that coldfusion could accept multiple database search keywords in a single string ? (perhaps seperated by commas)
kglad
Community Expert
Community Expert
July 23, 2007
if you want to separate by commas use: