Advertisement

04.27.2005 at 09:47AM PDT, ID: 21404598
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.0

Using Javascript and PHP to Create Dynamic Drop Downs

Asked by EmpKent in PHP and Databases

Tags: ,

I am trying to create a dynamic drop down. What I want is a pull down that contains a list of countries that is queried from a table. Once the user selects a country, the next drop down will then contain all the regions that are associated with that country. I am quite familiar with PHP but not too much with Javascript. My code is posted below. Right now, the code just doesn't do anything. I have a list of the countries and when I select one, the fill_sub() function just doesn't do it's part.

If someone could please point out my errors, that would be so much help.

Here is the code:

<?PHP
include '/data/www/connect.include';
?>
<HTML>
<HEAD>
<SCRIPT language="JavaScript">
<!--
function Fill_Sub()
{
         var country = document.FormName.country;
         var region = document.FormName.region;
      if( country.options[country.selectedIndex].value != 0 )
      {  
                region.length = 0;
         }
          <?PHP
          $query = "SELECT country FROM tblcountry order by country";
          $result = odbc_exec($connect, $query);
          while( $Row = odbc_fetch_array($Result) )
      {
               ?>
            if( country.options[country.selectedIndex].text == "<?PHP echo $Row[Country]; ?>" )
            {
                       <?PHP      
                  $Query2 = "SELECT region FROM tblcountry WHERE country = '$Row[Country]'";
                      $Result2 = odbc_exec($connect, $Query2);
                        $ctr = 0;
                  While( $Row2 = odbc_fetch_array($Result2) )
                  {
                               echo "region.options[$ctr] = new Option('$Row2[Region]')";
                               echo "region.options[$ctr].value = '$Row2[Region]'";
                               $ctr++;
                        }
                       ?>
                }
      <?PHP
        }
?>  
}
-->
</SCRIPT>
</HEAD>

<BODY>
 <FORM name="FormName" method="POST" action="">
  <TABLE>
   <TR>
    <TD>Country: <SELECT name="country" onchange="Fill_Sub();">
      <option selected>
      <?PHP
      $query = "SELECT * FROM tblcountry ORDER BY Name";
      $result = odbc_exec($connect, $query) or die ("Query Failed");
      for ($i = 0; $i < odbc_num_rows( $result ); ++$i)
      {
            $line = odbc_fetch_array($result);?>
            <option><?PHP echo $line[Name];
      }
      ?>
      </SELECT></TD>
          <TD>Region: <SELECT name="region">
      <option selected>
      <option>Select a country</SELECT></TD>
   </TR>
  </TABLE>
 </FORM>
</BODY>
</HTML>

Thank you for your help in advance.Start Free Trial
[+][-]04.27.2005 at 10:19AM PDT, ID: 13878435

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.27.2005 at 11:05AM PDT, ID: 13878832

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.27.2005 at 11:35AM PDT, ID: 13879140

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.27.2005 at 11:40AM PDT, ID: 13879194

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.27.2005 at 11:52AM PDT, ID: 13879281

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.04.2005 at 08:36AM PDT, ID: 13927751

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.04.2005 at 08:52AM PDT, ID: 13927927

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.04.2005 at 09:57AM PDT, ID: 13928534

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.04.2005 at 11:34AM PDT, ID: 13929348

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.04.2005 at 11:36AM PDT, ID: 13929365

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.04.2005 at 01:27PM PDT, ID: 13930446

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.04.2005 at 01:31PM PDT, ID: 13930475

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.04.2005 at 01:48PM PDT, ID: 13930657

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.04.2005 at 01:54PM PDT, ID: 13930711

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: PHP and Databases
Tags: php, dynamic
Sign Up Now!
Solution Provided By: Batalf
Participating Experts: 3
Solution Grade: A
 
 
[+][-]05.04.2005 at 01:59PM PDT, ID: 13930749

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.04.2005 at 02:01PM PDT, ID: 13930767

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.10.2005 at 05:26AM PDT, ID: 13967567

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32