469,619 Members | 1,885 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,619 developers. It's quick & easy.

Reloading a second box using dojo frame work

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
7 6770
acoder
16,027 Expert Mod 8TB
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
raknin
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
16,027 Expert Mod 8TB
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
raknin
82
Thanks acoder for the fast reply but for the moment I want to stay inside the dojo framework.
Mar 2 '08 #5
acoder
16,027 Expert Mod 8TB
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
Ixhel
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
Ixhel
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.

Similar topics

2 posts views Thread by Ike | last post: by
3 posts views Thread by src_mag | last post: by
1 post views Thread by purespam | last post: by
83 posts views Thread by liketofindoutwhy | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.