Reloading a second box using dojo frame work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raknin
    New Member
    • Oct 2007
    • 82

    #1

    Reloading a second box using dojo frame work

    Hi,

    Hi,

    Now that I am handle the way of use the dojo combobox I moving to the next stage. What I want to do is updating a second combobox automatically when a value is selected in the first combobox. I have a php that can handle the server side. Any suggestion how it can be done with dojo.
    I believe the code below can help other to start a dojo combobox.

    Please find my dojo code:

    [CODE=html]<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Simple ComboBox</title>
    <style type="text/css">
    @import "./dijit/themes/tundra/tundra.css";
    // @import "./dojo/resources/dojo.css"
    </style>
    <script type="text/javascript" src="./dojo/dojo.js"
    djConfig="parse OnLoad: true"></script>
    <script type="text/javascript">
    dojo.require("d ojo.parser");
    dojo.require("d ijit.form.Combo Box");
    dojo.require("d ojo.data.ItemFi leReadStore");
    function setCountry(valu e) {
    console.debug(" Selected "+value);
    }
    function setState(value) {
    console.debug(" Selected "+value);

    }
    </script>
    </head>
    <body class="tundra">


    <div dojoType="dojo. data.ItemFileRe adStore" jsId="countrySt ore"
    url="http://192.168.2.6:808 0/src/autocomplete/autocomplete.ph p?table_name=co untries_list &column_name=na me&row_id=Count ryID&dependency _column=''&depe ndency_value='' ">
    </div>
    <br> Country: <br>
    <input dojoType="dijit .form.ComboBox"
    store="countryS tore"
    value=""
    style="width:15 0px;font-size:12px;"
    maxListLength=" 2"
    searchAttr="nam e"
    name="state2"
    onChange="setCo untry" />


    <br> State: <br>
    <div dojoType="dojo. data.ItemFileRe adStore" jsId="stateStor e"
    url="http://192.168.2.6:808 0/src/autocomplete/autocomplete.ph p?table_name=us a_states &column_name=st ate_name&row_id =state_id&depen dency_column='' &dependency_val ue=''">
    </div>

    <input dojoType="dijit .form.ComboBox"
    store="stateSto re"
    value=""
    searchAttr="nam e"
    name="state_nam e"
    onChange="setSt ate" />
    </body>[/CODE]


    Thanks
    Ronen
    Last edited by acoder; Mar 2 '08, 01:59 PM.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Originally posted by raknin
    What I want to do is updating a second combobox automatically when a value is selected in the first combobox.
    Update with what? A state list? You can use setCountry() for this because it's called onchange.

    Comment

    • raknin
      New Member
      • Oct 2007
      • 82

      #3
      Acoder,

      Yes,I am aware of it, but my problem is that I don't know how to call the state combobox from the setCountry call back function, i.e reload the state combobox again(Call the server and update the combobox accordingly with the value entered in the country combobox).. This is what I need help about.
      The value of the selected value in the country combox is stored in the value attribute pass to the setCountry callback function.

      Thanks
      Ronen

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by raknin
        but my problem is that I don't know how to call the state combobox from the setCountry call back function, i.e reload the state combobox again(Call the server and update the combobox accordingly with the value entered in the country combobox).. This is what I need help about.
        If you want to avoid a page refresh, use Ajax. Pass the value to the server-side script which will return the combo box values according to the value passed. See an example. You could return the whole combo box and set the innerHTML or just return the values which you can use to construct the option tags in the combo box.

        Comment

        • raknin
          New Member
          • Oct 2007
          • 82

          #5
          Thanks acoder for the fast reply but for the moment I want to stay inside the dojo framework.

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            You can still use the dojo framework. It'll probably have some Ajax methods.

            Another alternative is to reload the page and pass the selected value. You can then take that value to populate the state combo box.

            Comment

            • Ixhel
              New Member
              • Sep 2010
              • 2

              #7
              Tal vez estás lo que buscas lo puedes hacer con FilteringSelect . Te dejo la liga, seguro que te será muy útil.

              Comment

              • Ixhel
                New Member
                • Sep 2010
                • 2

                #8
                En dojo no necesitas () para llamar una función

                Comment

                Working...