HI Pascal, its actually easier than that. You don't need to remove and add individual elements, you can simply replace the property ".elementsArray" of the second selectionList, e.g. ------- selectionList2.elementsArray = newArray; selectionList2.selectElementByPosition(0,false); -------
note that I propose to also call the method .selectElementByPosition() to make sure that the second selectionlist now displays a valid value of the new array. As an example see http://www.carto.net/papers/svg/gui/selectionlist/ index.svg see the two selectionlists at the upper right. See http://www.carto.net/papers/svg/gui/selectionlist/init.js and the function "updateNumbers2" to see how I set the new values. you can query a new array from the database on the server using a network request (XMLHttpRequest and getURL). The same also works for comboboxes: see http://www.carto.net/williams/ yosemite/, go to the "Search" tab and enter something in the texbox. As you type the values in the combobox are populated with the results of a database query. Hope this helps, Andreas --- In [email protected], "pascal.benoist" <[EMAIL PROTECTED]> wrote: > > Hello, > > I just developpe a little query builder for my svg application and i > use SelectionLists from carto.net > > I would like to populate automatically a selectionList from the > choice made in a preceding selectionList. > First, I create 2 selectionLists (selectionList1 and selectionList2) > The first one is populated directly at the creation. > The second one is first populated with a empty array. > > I choose a value in SelectionList1 > Then , I run a PHP script with this parameter, request my DB (I > request : > DESCRIBE <MyTable> ) with <MyTable> the item selected in > selectionList1 Then, I would like to automatically populate > selectionList2 with the values return from the request (those values > are the Fields of <MyTable>) > > Would you have any tutorial that explain that? > > Secondly, I cannot understand why the above Javascript code does not > work : > function updateSelectionList > selectionListName,selectedIndex,selectedValue) > { > // reinitialisation de selectionListDynLayer > position = 0; > while > (selectionListDynLayer.selectElementByPosition(position,false)) { > MyAlert("deleting element position " + position > + " : " + selectionListDynLayer.getCurrentSelectionElement()); > > selectionListDynLayer.deleteElement > (selectionListDynLayer.getCurrentSelectio > nElement()); > position++; > } > > MyAlert("selected : " + selectedValue); > selectionListArray = new > Array(getSelectionListArray(selectedValue)); > > MyAlert("selectionListArray : " + selectionListArray); > for (i=0;i<selectionListArray.length;i++) { > selectionListDynLayer.addElementAtPosition(selectionListArray > [i],i); > } > } > > function getSelectionListArray(MyTable) { > PHPFileName = "../files/getSelectionListArray.php?MyTable=" > + MyTable; > getDataObjSelectionListArray.url=PHPFileName; > getDataObjSelectionListArray.getData(); > } > > function callbackSelectionListArray(theNode) { > MyAlert("callback:" + printNode(theNode)); > return theNode; // not sure it is a good idea ... > } > > Thanks > ----- To unsubscribe send a message to: [EMAIL PROTECTED] -or- visit http://groups.yahoo.com/group/svg-developers and click "edit my membership" ---- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/svg-developers/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

