2

I'm trying to populate a searchable dropdown list with specific values, but I would like to combine two of the values and have them return results for either value. For example:

                <td align="left" valign="top" nowrap>
                <select name="SPORTS" 
                        id="idCustom1" 
                        onChange="AddSearchItem(this);"
                        class="StuFindSelect">
         <option value="    ">No Attribute selected
                   <option value="BASEBALL">Baseball
                   <option value="BASKETBM">Mens Basketball
                   <option value="BASKETBW">Womens Basketball
                   <option value="CHEERLDS">Cheerleader
                   <option value="FOOTBALL">Football
                   <option value="GOLF">Golf
                   <option value="LACROSSW">Womens Lacrosse
                   <option value="SOCCERM">Mens Soccer
                   <option value="SOCCERW">Womens Soccer
                   <option value="TENNISM">Mens Tennis
                   <option value="TENNISW">Womens Tennis
                   <option value="TRACK">Track
                   <option value="VOLLEYBL">Volleyball
                   <option value="XCOUNTM">Mens Cross Country
                   <option value="XCOUNTW">Womens Cross Country
                </select>
            </td>

I want to combine the results that return BASKETBM or BASKETBW when a user selects Basketball. After researching I've tried combining them in several different ways,

<option value="[BASKETBM,BASKETBW]">Basketball
<option value="BASKETBM,BASKETBW">Basketball
<option value="BASKETBM|BASKETBW">Basketball

and every other permutation I could find, but nothing seems to work. Everytime it returns zero search results when testing it. Any ideas what I'm doing wrong? Thanks.

aynber
  • 22,380
  • 8
  • 50
  • 63
rkw2
  • 21
  • 1
  • It may help posting the code for the `AddSearchItem` function as it's hard to determine what your expected functionality is without knowing what "returns zero search results when testing." – sbeliv01 Apr 02 '13 at 21:36
  • You might want to check out [**this question**](http://stackoverflow.com/questions/3245967/can-an-option-in-select-tag-carry-multiple-values) – zajd Apr 02 '13 at 21:53
  • Thanks, the AddSearchItem function adds the selected option value to the search criteria. The question you linked me to is where I started off trying to figure this out. – rkw2 Apr 02 '13 at 22:26

1 Answers1

0

I do not know what AddSearchItem(this); does, as a function, but I'm guessing the problem is there. Maybe you can detail more this part of your question.

You can without problem have an option like this:

<option value="BASKETBM,BASKETBW">Basketball

and use this.value.split(',') to get values out of it.

  • Thanks, Where do I use this.value.split(',') in the code to get values out of it? – rkw2 Apr 02 '13 at 22:26
  • Well, it depends how your AddSearchItem works. It seems that you pass it the select, and not the selected value, which is quite strange to me, but as I don't have the code of the function, I can't be sure what you do with it. – alicelieutier Apr 02 '13 at 23:00
  • A very naive guess would be that you need to use `AddSearchItem(this.value.split(','));`, but this could be totally wrong, as I said, I can't really answer without the code of `AddSearchItem()` – alicelieutier Apr 02 '13 at 23:05