[Cartoweb-users] How to use dropdownlist with data from database

Oliver Christen oliver.christen at camptocamp.com
Thu Sep 13 04:29:25 EDT 2007


Hi

do it in two phase.

first make a plugin that will return the list of values for the select.
but instead of producing html, simply output a string with the values separated by comma, like this: 
option1,option2, option3, ... 
if the option name is different from the option value, simply generate two string
you do this in the renderform function of your plugin, by setting, for example $optionNamesList = 'option1name,option2name,...' and $optionValuesList = 'option1value,...'

and in your template, add this somewhere:

<script type="text/javascript">
  /*<![CDATA[*/
    var optionNamesList = '{$optionNamesList}';
    var optionValuesList = '{$optionValuesList}';
  /*]]>*/
</script>

this way to can access the options data via the edit plugin javascript

the edit plugin javascript is complex, maybe ask someone who know javascript to help you with that part

In the actual HowToAddDropdownInEditPlugin example, the options data is written in hard in the code. All you have to do is, instead, get the optionNamesList and optionValuesList javascript variable (defined in the template, see above).

so, instead of using 
var authorisedOptionsList = new array( ...
var authorisedOptionsListLabel = new array( ...

you use
var authorisedOptionsList = optionValuesList.split(",");
var authorisedOptionsListLabel = optionNamesList.split(",");

this convert the string provided by your other plugin into an array of options label and value the javascript from the edit plugin can use.

regards
Oliver
  Hey all,
  If i want to use the example given in the wiki for retrieving data from server (http://cartoweb.org/cwiki/HowToReturnDataFromServerToClient), but i want to return this data list to the javascript that constructs an edit table (in edit plugin), how would i do that? I want to combine the above HowTo and the dropdownlist(http://cartoweb.org/cwiki/HowToAddDropdownInEditPlugin) HowTo.
  Am not a pro in these things (javascripts, php)
  Thanks
  Broun Uganda



------------------------------------------------------------------------------
  Get news, entertainment and everything you care about at Live.com. Check it out! 


------------------------------------------------------------------------------


  _______________________________________________
  Cartoweb-users mailing list
  Cartoweb-users at lists.maptools.org
  http://lists.maptools.org/mailman/listinfo/cartoweb-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-users/attachments/20070913/ab94bbbe/attachment.html


More information about the Cartoweb-users mailing list