Welcome Guest, Not a member yet? Register   Sign In
field dependencies
#1

[eluser]Unknown[/eluser]
Hi guys I need your help.
I have a page with 6 fields.
But I cannot figure out and have no clue about the code how to make them dependant from each other.
Example: if someone chooses from the 1 field (country) Africa, then the second field should just give the user the fields from the towns in Africa (all fields just show the countries, towns, which are saved in the database.

Please help me. Thanks!

Code:
<style type="text/css">
    .search_panel { width: 250px; margin: 10px 0; }
    .search_panel input { width: 220px; border: 2px solid #000643; padding: 5px; }
    .search_panel select { width: 230px; border: 2px solid #000643; padding: 5px; }
</style>
[removed]
$(function() { $( "#course_start_date" ).datepicker(); });


[removed]
<div id="home">
  <div style="width: 500px; height:260px; padding: 40px 50px; margin: 0 auto; background-image: url(&lt;?=base_url()?&gt;images/front_blue.png); background-repeat: no-repeat;">
    
    &lt;form method="post" action="&lt;?=site_url('search')?&gt;"&gt;
        
        <div class="search_panel" style="float: left;">
    
            <select name="country" style="">
                <option value="">Choose a country</option>
                &lt;?php if($countries): foreach($countries as $country): ?&gt;
                    <option value="&lt;?=$country->school_country?&gt;">&lt;?=$country->school_country?&gt;</option>
                &lt;?php endforeach; endif; ?&gt;
            </select>

      </div>
        
        <div class="search_panel" style="float: left;">
            
            <select name="city">
                <option value="">Choose a city</option>
                &lt;?php if($cities): foreach($cities as $city): ?&gt;
                    <option value="&lt;?=$city->school_city?&gt;">&lt;?=$city->school_city?&gt;</option>
                &lt;?php endforeach; endif; ?&gt;
            </select>
            
        </div>
        
        <br clear="all"/>
        
        <div class="search_panel" style="float: left;">
            
            &lt;input type="text" name="starting_date" id="course_start_date" value="Choose a starting date"&gt;
                        
        </div>
        
        <div class="search_panel" style="float: left;">
            
            <select name="course_type">
                <option value="">Choose a course type</option>
                &lt;?php if($course_types): foreach($course_types as $course_type): ?&gt;
                    <option value="&lt;?=$course_type->course_type?&gt;">&lt;?=$course_type->course_type?&gt;</option>
                &lt;?php endforeach; endif; ?&gt;
            </select>
            
        </div>
        
        <br clear="all"/>

        <div class="search_panel" style="float: left;">            
            
            <select name="school_name">
                <option value="">Search by school name</option>
                &lt;?php if($schools): foreach($schools as $school): ?&gt;
                    <option value="&lt;?=$school->school_name?&gt;">&lt;?=$school->school_name?&gt;</option>
                &lt;?php endforeach; endif; ?&gt;
            </select>
            
        </div>
        
        <div class="search_panel" style="float: left;">
            
            <select name="language">
                <option value="">Search by language</option>
                &lt;?php if($languages): foreach($languages as $language): ?&gt;
                    <option value="&lt;?=$language?&gt;">&lt;?=$language?&gt;</option>
                &lt;?php endforeach; endif; ?&gt;
            </select>
            
        </div>
        
        <br clear="all"/>
        
        <center>
          <p><br />
            &lt;input type="image" src="&lt;?=base_url()?&gt;images/search.png"/&gt;
          </p>
      </center>

    &lt;/form&gt;
        
  </div>

</div>
#2

[eluser]toopay[/eluser]
Write some ajax to do that!




Theme © iAndrew 2016 - Forum software by © MyBB