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

Oliver Christen oliver.christen at camptocamp.com
Wed Nov 14 08:42:23 EST 2007


Hi

you dont really need the CDATA tag but it is a more correct syntax for xhtml.

as for your other question, well, passing data from server side to client side is certainly possible but you will need probably as much code fot that than you would need to access the data from the client side.
see http://www.cartoweb.org/cwiki/HowToReturnDataFromServerToClient (you can ignore the wsdl part)

regards
Oliver
  ----- Original Message ----- 
  From: Broun Uganda 
  To: Oliver Christen ; cartoweb-users at lists.maptools.org 
  Sent: Wednesday, November 14, 2007 1:01 PM
  Subject: RE: [Cartoweb-users] How to use dropdownlist with data from database


  Dear All
  Thank you Oliver for your detailed advice. I can now retrieve data into the dropdownlist, although i did not construct a new plug in: wrote an external php function to retrieve item names from database which i call from ClientEdit renderform function in edit plugin. My question related to this is: How do i use this function instead from the Server side so i can take advantage of the already constructed dsn? ( i now have to make another connection to database.)
  Do i need this? I didnt use it and it works!
     /*<![CDATA[*/       .........................            /*]]>*/

  Broun Uganda





----------------------------------------------------------------------------
    From: oliver.christen at camptocamp.com
    To: tekuganda at hotmail.com; cartoweb-users at lists.maptools.org
    Subject: Re: [Cartoweb-users] How to use dropdownlist with data from database
    Date: Thu, 13 Sep 2007 10:29:25 +0200


    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




------------------------------------------------------------------------------
  Get news, entertainment and everything you care about at Live.com. Check it out! 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/cartoweb-users/attachments/20071114/a5100b07/attachment-0001.html


More information about the Cartoweb-users mailing list