By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,215 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

Reloading a second box using dojo frame work

P: 82
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:

Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  3. <title>Simple ComboBox</title>
  4.     <style type="text/css">
  5.         @import "./dijit/themes/tundra/tundra.css";
  6.  //       @import "./dojo/resources/dojo.css"
  7.     </style>
  8.     <script type="text/javascript" src="./dojo/dojo.js"
  9.         djConfig="parseOnLoad: true"></script>
  10.     <script type="text/javascript">
  11.        dojo.require("dojo.parser");
  12.        dojo.require("dijit.form.ComboBox");
  13.        dojo.require("dojo.data.ItemFileReadStore");
  14.        function setCountry(value) {
  15.            console.debug("Selected "+value);
  16.        }
  17.        function setState(value) {
  18.            console.debug("Selected "+value);
  19.  
  20.        }
  21.    </script>
  22. </head>
  23. <body class="tundra">
  24.  
  25.  
  26.      <div dojoType="dojo.data.ItemFileReadStore" jsId="countryStore"
  27.               url="http://192.168.2.6:8080/src/autocomplete/autocomplete.php?table_name=countries_list &column_name=name&row_id=CountryID&dependency_column=''&dependency_value=''">
  28.               </div>
  29. <br> Country: <br>             
  30.      <input dojoType="dijit.form.ComboBox"
  31.                 store="countryStore"
  32.                 value=""
  33.                 style="width:150px;font-size:12px;" 
  34.                 maxListLength="2" 
  35.                 searchAttr="name"
  36.                 name="state2"
  37.                 onChange="setCountry" />
  38.  
  39.  
  40. <br> State: <br>                             
  41.    <div dojoType="dojo.data.ItemFileReadStore" jsId="stateStore"
  42.               url="http://192.168.2.6:8080/src/autocomplete/autocomplete.php?table_name=usa_states &column_name=state_name&row_id=state_id&dependency_column=''&dependency_value=''">
  43.               </div>
  44.  
  45.      <input dojoType="dijit.form.ComboBox"
  46.                 store="stateStore"
  47.                 value=""
  48.                 searchAttr="name"
  49.                 name="state_name"
  50.                 onChange="setState" />               
  51. </body>

Thanks
Ronen
Mar 2 '08 #1
Share this Question
Share on Google+
7 Replies


acoder
Expert Mod 15k+
P: 16,027
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.
Mar 2 '08 #2

P: 82
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
Mar 2 '08 #3

acoder
Expert Mod 15k+
P: 16,027
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.
Mar 2 '08 #4

P: 82
Thanks acoder for the fast reply but for the moment I want to stay inside the dojo framework.
Mar 2 '08 #5

acoder
Expert Mod 15k+
P: 16,027
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.
Mar 3 '08 #6

P: 2
Tal vez estás lo que buscas lo puedes hacer con FilteringSelect. Te dejo la liga, seguro que te será muy útil.
http://docs.dojocampus.org/dijit/form/FilteringSelect
Sep 9 '10 #7

P: 2
En dojo no necesitas () para llamar una función
Sep 9 '10 #8

Post your reply

Sign in to post your reply or Sign up for a free account.