[Dojo-interest] Re: Syncing Select Boxes

David Petersen david at dipetersen.com
Wed Feb 21 09:13:53 MST 2007


After much trial and error, I figured out how to use the dojo.io.bind
to accomplish the task.  Here's what I came up with.

I set the first SELECT box's onValueChanged property to call
filterAfterStatusChange. That gave me the "val" I wanted for the
second SELECT box.  I have an ASP page that creates a JSON response
and the io.bind just consumes it and sets the data in the second
select box.  Even though this works, I may try the other suggestions
received so far.

	function filterAfterStatusChange(val){
		var mySelect = dojo.widget.byId('ft01'); //second select box
                //set new url path
		mySelect.dataUrl = 'DoJoData.asp?method=GetComboMappings&filter='+val;
		// zero out currently selected values.  I suppose you could preserve
the selecte
                // value just in case that is a valid selection for
the new data.  I don't need to.
                mySelect.setAllValues('','');
		dojo.io.bind({
			url: mySelect.dataUrl,
			load: function(type, data, evt){
			if(type=="load"){
				mySelect.dataProvider.setData(data);
			    }
			},
			mimetype: "text/json"
		});
	}	


On 2/20/07, David Petersen <david at dipetersen.com> wrote:
> I have two dojo.Select drop-down boxes.  The first is populated by a
> dataUrl. The second will be populated dynamically with the value
> selected in the first one.  I have searched through all of the
> documentation that I could find to find a way to force the second box
> to reload.
>
> on the first SELECT box I set the onValueChanged to a function. That
> function assigned the second SELECT box's dataURL to something like
> "getData.asp?method=filtered&value=5".
>
> The boxes load if I initially set this value but if I dynamically try
> to set the value, nothing happens.  Have I missed a method that
> refreshes the data?
>
> Thanks
>


More information about the Dojo-interest mailing list