Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Regular Coder
    Join Date
    Dec 2007
    on earth
    Thanked 2 Times in 2 Posts

    Adding dependancies between select lists

    Hello guys,

    I am using the javascript from:

    I have added a third row of selection by adding into the <script>:

    function getStateList(sel)
    	var countryCode = sel.options[sel.selectedIndex].value;
    	document.getElementById('dhtmlgoodies_state').options.length = 0;	// Empty city select box
    		var index = ajax.length;
    		ajax[index] = new sack();
    		ajax[index].requestFile = 'getCities.php?countryCode='+countryCode;	// Specifying which file to get
    		ajax[index].onCompletion = function(){ createState(index) };	// Specify function that will be executed after file has been found
    		ajax[index].runAJAX();		// Execute AJAX function
    function createState(index)
    	var obj = document.getElementById('dhtmlgoodies_state');
    	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code	
    and into html
    		<td><h1>State:</h1> </td>
    		<td><select id="dhtmlgoodies_state" name="dhtmlgoodies_state" onchange="getCityList(this)">
    Does anyone know how to add dependencies so that the second selection appears (graphically) after the first one is selected, and the third one after the second?

    That would help me much because there is a slight bug with this script, now I added a row (when third selected, selecting back to the first makes second only empty...) and this would sort it + would look fancier obviously.

    I found a post here about this effect: Multiple Select Boxes
    but since I am using a lot of variables in my lists (50), it would be a pain to use this technique.

    Thanks a lot!
    Last edited by mikacruz; 07-25-2009 at 08:44 PM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts