Announcement Announcement Module
Collapse
No announcement yet.
Update selected value in combobox using dojo Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Update selected value in combobox using dojo

    Hi All,

    I've got a form that contains 2 comboboxes. When the user selects a value in the first combobox, I would like the value in the second combobox to be updated i.e if the first combobox contained cities, and the second counties, I would like the second combo to be updated with the correct county when the city is selected.

    Unfortunately, no matter what I try, I can't get it to work. I'm using Spring-js, but I'm relatively new to it. Here's my latest attempt. Any help would be very much appreciated.

    Code:
    <script>
    function serviceLineIdOnChange() {
    	var serviceLine=arguments[0]; // the new value
    	if (serviceLine=='1') { // SI
    		setSelectedItem('_engagementTypeId_id', 'TBC');
    	} else {
    		setSelectedItem('_engagementTypeId_id', '');
    	} 			
    }
    
    function setSelectedItem(selectId, value){
    	combobox = dijit.byId(selectId);
    	combobox.attr('value', value);
    }
    </script>
    
    <div id="serviceLine_id">
    	<b><label for="_serviceLine_id">Service Line:</label></b>
    	<select id="_serviceLine_id" name="serviceLine" >
    		<option value="-1"></option> <option value="1">SI</option> 
    	</select> 
    	<br/><script type="text/javascript">
    		Spring.addDecoration(new Spring.ElementDecoration({elementId : '_serviceLine_id', widgetType: 'dijit.form.FilteringSelect', widgetAttrs : {hasDownArrow : true}})); 
    	</script> 
    </div> 
    
    
    
    <div id="engagementTypeId_id">
    	<b><label for="_engagementTypeId_id">Engagement Type:</label></b>
    	<select id="_engagementTypeId_id" name="engagementTypeId" >
    		<option value="-1"></option> <option value="1">TBC</option> 
    	</select> 
    	<br/><script type="text/javascript">
    		Spring.addDecoration(new Spring.ElementDecoration({elementId : '_engagementTypeId_id', widgetType: 'dijit.form.FilteringSelect', widgetAttrs : {hasDownArrow : true}})); 
    	</script> 
    </div> 
    
    <script>
        		dojo.connect(dijit.byId('_serviceLine_id'), 'onChange', 'serviceLineIdOnChange'); 
        	});
    </script>
Working...
X