Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder olidenia's Avatar
    Join Date
    Oct 2009
    Location
    Sitting In Front Of A Screen
    Posts
    110
    Thanks
    16
    Thanked 4 Times in 4 Posts

    A little help with this script

    Can someone help me or point me in the right direction to enable browser back button on this script:

    Code:
    var ajax = new Array();
    
    function getCityList(sel)
    {
    	var countryCode = sel.options[sel.selectedIndex].value;
        document.getElementById('dhtmlgoodies_city').options.length = 0;	// Empty city select box
    	if(countryCode.length>0){
    		var index = ajax.length;
    		ajax[index] = new sack();
    
    		ajax[index].requestFile = 'getCities.php?countryCode='+countryCode;	// Specifying which file to get
    		ajax[index].onCompletion = function(){ createCities(index) };	// Specify function that will be executed after file has been found
    		ajax[index].runAJAX();		// Execute AJAX function
    	}
    }
    
    function createCities(index)
    {
    	var obj = document.getElementById('dhtmlgoodies_city');
    	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code
    }
    
    function getSubCategoryList(sel)
    {
    	var category = sel.options[sel.selectedIndex].value;
    	document.getElementById('dhtmlgoodies_subcategory').options.length = 0;	// Empty city select box
    	if(category.length>0){
    		var index = ajax.length;
    		ajax[index] = new sack();
    
    		ajax[index].requestFile = 'getSubCategories.php?category='+category;	// Specifying which file to get
    		ajax[index].onPageload = function(){ createSubCategories(index) };	// Specify function that will be executed after file has been found
    		ajax[index].runAJAX();		// Execute AJAX function
    	}
    }
    function createSubCategories(index)
    {
    	var obj = document.getElementById('dhtmlgoodies_subcategory');
    	eval(ajax[index].response);	// Executing the response from Ajax as Javascript code
    }
    PHP page:
    Code:
    <p>
    Area
    <select name="province" onchange="getCityList(this)"> 
    <option value="">Select Area</option> 
    <option value="1"> Area 1</option> 
    <option value="2"> Area 2</option> 
    <option value="3"> Area 3</option> 
    <option value="4"> Area 4</option> 
    <option value="5"> Area 5</option> 
    <option value="6"> Area 6</option> 
    <option value="7"> Area 7</option> 
    <option value="8"> Area 8</option> 
    </select>
    </p>
    
    <!-- Populate city town from area dropdown -->
    <p>
    City/Town<select value="" id="dhtmlgoodies_city" name="town"></select>
    </p>
    Last edited by olidenia; 10-14-2010 at 12:30 PM.

  • #2
    Regular Coder hdewantara's Avatar
    Join Date
    Aug 2009
    Location
    Jakarta, Indonesia.
    Posts
    372
    Thanks
    9
    Thanked 54 Times in 53 Posts
    Use cookies?

  • #3
    New Coder
    Join Date
    Jun 2005
    Posts
    52
    Thanks
    0
    Thanked 4 Times in 4 Posts


  •  

    Posting Permissions

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