SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help on drop down lists.

    i have 2 drop down lists which is the 2nd drop down list is depending on the 1st drop down list.

    1. symptom classification
    2. symptom category

    values in symptom classfication are loaded from an array while values in symptom category are loaded from the database based on selected value from symptom classification. but, the values are not show up in the 2nd drop down list whenever user selects any value from 1st drop down list.

    1. symptoms_signs_block.php

    PHP Code:
    <?php
    ini_set
    ('display_errors'1); 
    error_reporting(E_ALL); 

    include(
    "../ecis_cfg.php");
    global 
    $ecisSymptom$classId;
    $classId = isset($_GET['classId']) ? $_GET['classId'] : ' ';

    ?>
    <style type="text/css">
    @import url(../css/style_registration.css);
    .style3 {font-size: 13px}
    body,td,th {
        font-size: 13px;
    }
    </style>
    <form name="form" method="post" action="../process/symptom.php?op=register">
      <table width="471" border="0">
        <tr>
          <td colspan="2" id="tblheader">Symptom Profile </td>
        </tr>
        <tr>
          <td width="116">Classfication</td>
          <td width="339">
          <select name="sym_class" id="sym_class" onChange="this.form.submit();">
          <option value="" selected>Select</option>
          <?php foreach($ecisSymptom->loadSymptomClassification() as $key=>$value){ ?>
              <?php if($key == $classId){ ?>
            <option value="<?php echo $key?>" selected><?php echo $value?></option>
            <?php } else { ?>
            <option value="<?php echo $key?>"><?php echo $value?></option>
          <?php } } ?>
          </select>      </td>
        </tr>
        <tr>
          <td>Category</td>
          <td>
          <select name="sym_cat" id="sym_cat">
          <option value="">Select</option>
            <?php $ecisSymptom->loadSymptomCategory($classId); ?>
          </select>
          [<a href="symptoms_signs_category_block.php">Add Category</a>] </td>
        </tr>
        <tr>
          <td>Name</td>
          <td><input name="sym_name" type="text" id="sym_name"></td>
        </tr>
        <tr>
          <td>Description</td>
          <td><textarea name="sym_desc" id="sym_desc"></textarea></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td><input type="submit" name="Submit" value="Submit"></td>
          <td>&nbsp;</td>
        </tr>
      </table>
    </form>
    2. symptom.php

    PHP Code:
    <?php
    ini_set
    ('display_errors'1); 
    error_reporting(E_ALL); 

    include(
    "../ecis_cfg.php");
    global 
    $ecisSymptom;

    # if dropdown list is changed
    if(!isset($_POST['Submit'])){
        if(isset(
    $_POST['sym_class']) && ($_POST['sym_class'] != "Select") && (isset($_GET['op']) == "register")){
            
    header("Location: ../templates/symptoms_signs_block.php?classId=".$_POST['sym_class']);
        }
    }

    # if Submit button is pressed
    if(isset($_POST['Submit'])){
        
    # process to add symptom category
        
    if(isset($_GET['op']) == "symcat"){
            if(empty(
    $_POST['sym_cat_class']) || empty($_POST['sym_cat_name'])){
                echo 
    "<strong>Warning:</strong> Please fill in all mandaratory fields.";
                echo 
    "<br><br>";
                echo 
    "<a href=\"../templates/symptoms_signs_category_block.php\">Back</a>";
            }
            else{
                if(
    $ecisSymptom->checkString($_POST['sym_cat_name']) == false){
                    echo 
    "<strong>Warning:</strong> <strong><u>" $_POST['sym_cat_name'] . "</u></strong> must be alphabet.";    
                    echo 
    "<br><br>"
                    echo 
    "<a href=\"../templates/symptoms_signs_category_block.php\">Back</a>";
                }
                else
                    
    $ecisSymptom->addSymptomCategory($_POST['sym_cat_class'], $_POST['sym_cat_name'], $_POST['sym_cat_desc']);
            }
        }

        
    # process to add symptom
        
    elseif(isset($_GET['op']) == "register"){
            if(empty(
    $_POST['sym_class']) || empty($_POST['sym_name']) || empty($_POST['sym_charac'])){
                echo 
    "<strong>Warning:</strong> Please fill in all mandaratory fields.";
                echo 
    "<br><br>";
                echo 
    "<a href=\"../templates/symptoms_signs_block.php\">Back</a>";
            }
            else{
                if(
    $ecisSymptom->checkString($_POST['sym_name']) == false){
                    echo 
    "<strong>Warning:</strong> <strong><u>" $_POST['sym_name'] . "</u></strong> must be alphabet.";    
                    echo 
    "<br><br>"
                    echo 
    "<a href=\"../templates/symptoms_signs_block.php\">Back</a>";
                }
                elseif(
    $ecisSymptom->checkString($_POST['sym_charac']) == false){
                    echo 
    "<strong>Warning:</strong> <strong><u>" $_POST['sym_charac'] . "</u></strong> must be alphabet.";    
                    echo 
    "<br><br>"
                    echo 
    "<a href=\"../templates/symptoms_signs_block.php\">Back</a>";
                }
                elseif(
    $ecisSymptom->checkSymptomName($_POST['sym_name']) == false){
                    echo 
    "<strong>Warning:</strong> <strong><u>" $_POST['sym_name'] . "</u></strong> profile already in the records.";    
                    echo 
    "<br><br>"
                    echo 
    "<a href=\"../templates/symptoms_signs_block.php\">Back</a>";
                }
                else
                    
    $ecisSymptom->addSymptom($_POST['sym_class'], $_POST['sym_name'], $_POST['sym_charac']);
            }
        }
    }
    ?>
    <style type="text/css">
    @import url(../css/style_registration.css);
    .style3 {font-size: 13px}
    body,td,th {
        font-size: 13px;
    }
    </style>
    3. ecissymptom.php

    PHP Code:
    function loadSymptomClassification()
        {
            
    $symptom_classification = array("01" => "Circulatory & Respiratory Systems [01]",
                                            
    "02" => "Cognition, Perception, Emotional State & Behaviour [02]",
                                            
    "03" => "Digestive System & Abdomen [03]",
                                            
    "04" => "General Symptoms & Signs [04]",
                                            
    "05" => "Nervous & Musculosketel Systems [05]",
                                            
    "06" => "Skin & Subcutaneous Tissue [06]",
                                            
    "07" => "Speech & Voice [07]",
                                            
    "08" => "Urinary System [08]");
            return 
    $symptom_classification;
        }
        
        function 
    loadSymptomCategory($sym_class)
        {    
            global 
    $ecisDB;
            
    $sql "SELECT symptomCategoryId, symptomCategoryName FROM Category WHERE symptomCategoryClassification = '$sym_class'";
            
    $query $ecisDB->query($sql);
            
            while(
    $result $ecisDB->fetch_array($query)){
                echo 
    '<option value="' $result['symptomCategoryId'] . '">' $result['symptomCategoryName'] . '</option>';
            }
        } 

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2005
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Solved & Closed

    thank you


Bookmarks

Posting Permissions

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