The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

Colleen (12) [Avatar] Offline
#1
Hi,
As you can see I love my Double Combo lists.

If I want the second drop down list to be a mulitselect I define it in php as follows:

<select name="ddlTerritory[]" size="4" multiple="multiple"></select>

originally was:
<select name="ddlTerritory"></select>.

I am not passing this the javascript function FillSuburb() properly because I get the following error:

"oTarget has no properties".

The FillSuburb javascript:
--------------------------------------------
<script type="text/javascript">
function FillSuburb(oElem,oTarget,pfield_name)
{
debugger;

var strValue = oElem.options[oElem.selectedIndex].value;
var url = "DoubleComboXML.php";


var strParams = "q=" + strValue +
"&f=" + oTarget.form.name +
"&e=" + oTarget.name +
"&g=" + pfield_name;

var loader1 = new net.ContentLoader(url,
FillDropDown,
null,
"POST",
strParams );

}
___________________________________________________

I know I am not passing the form element " ddlTerritory[]" properly to the javascript.
My javascript is weak ...my XML not much better but ....hey, I'm TRYING.

Thanks ,
Colleen
kurinosuke (156) [Avatar] Offline
#2
Re: DoubleCombo - with a MULTI select in the second option list
Hi Colleen !

I'm not sure that you can use brackets in the element's name. Even if you can, maybe you should simply avoid using them. Please try to change the name back to "ddlTerritory", or give it a name like "ddlTerritories" smilie
Colleen (12) [Avatar] Offline
#3
Re: DoubleCombo - with a MULTI select in the second option list
thank you.

I would love to avoid using the '[]' in my field name but if I don't my muliti-selection will not work because it won't store the selected options in an array ... only the last selection.

Never mind. I will figure out another way but thank you anyway.
kurinosuke (156) [Avatar] Offline
#4
Re: DoubleCombo - with a MULTI select in the second option list
You can get the selected items by looping through the options :
for(var i = 0;i < myCombo.length;i++){
if(myCombo.options[i].selected == true) {
doSomething();
}
}
Colleen (12) [Avatar] Offline
#5
Re: DoubleCombo - with a MULTI select in the second option list
Thank you. That works.