mardi 2 février 2016

display checkbox items list except selected dropdown item

I have dropdown list of items and popup(used colorbox for opening popup) checkbox list of items on click of '+Add/Edit' button which both reads data from complaint.csv file.

enter image description here enter image description here

complaint.csv file

1,complaint type 1
2,complaint type 2
3,complaint type 3
4,complaint type 4
5,complaint type 5
6,complaint type 6
7,complaint type 7
8,complaint type 8
9,complaint type 9

PHP code

<label class="question-name" ng-class="{error:hasError()}">  <span class="ng-binding" ng-hide="question.nameHiddenOnMobile">Chief Complaint </span>  <span class="icon-required" ng-show="question.required"></span>  </label>

       <select name="Language.PrimarySpoken" ng-hide="showAddAnswer" ng-model="question.response.value" ng-options="a.text as a.getText() for a in question.answers.items" id="Language.PrimarySpoken" ng-value="a.text" class="input-wide " ng-class="{error:hasError()}" onchange="selectAnswer(this)">
   <option class="hidden" disabled="disabled" value=""></option>

<?php

$file_handle = fopen("../complaint.csv", "r");

while (!feof($file_handle)) {

$lines_of_text[] = fgetcsv($file_handle, 1024);

}
fclose($file_handle);

foreach ( $lines_of_text as $line_of_text): ?>
        <option value="<?php print $line_of_text[0]; ?>"><?php print $line_of_text[1]; ?></option>

  <?php endforeach; ?>
</select>
        <br/> <br/>
        <label class="question-name" ng-class="{error:hasError()}">  <span class="ng-binding" ng-hide="question.nameHiddenOnMobile">Additional Complaint </span>  <span class="icon-required" ng-show="question.required"></span>  </label>

         <div class="form-row added ng-binding" ng-bind-html="question.getText()" id="text" ></div>
       <div class="form-row addlink ng-binding" ng-bind-html="question.getText()"><em><a class='inline' href="#inline_content">+ Add/Edit</a></em></div>

        <div style='display:none'>
            <div id='inline_content' style='padding:25px; background:#fff; font-size: 17px;'>

                <form action="" id="popup_form">

   <?php

    // Setup ---------------------------------------------------------------        
    define('numcols',4);  // set the number of columns here
    $csv = array_map('str_getcsv', file('../complaint.csv'));
    $numcsv = count($csv);
    $linespercol = floor($numcsv / numcols);
    $remainder   = ($numcsv % numcols);
    // Setup ---------------------------------------------------------------        


    // The n-column table --------------------------------------------------
    echo '<div class="table">'.PHP_EOL;
    echo '   <div class="column">'.PHP_EOL;

    $lines = 0;
    $lpc   = $linespercol;
    if ($remainder>0) { $lpc++; $remainder--; }
    foreach($csv as $item) {
        $lines++;
        if ($lines>$lpc) {
            echo '   </div>' . PHP_EOL . '<div class="column">'.PHP_EOL;
            $lines = 1;
            $lpc   = $linespercol;
            if ($remainder>0) { $lpc++; $remainder--; }
        }
        echo '      <label class="checkbox" for="checkbox'.$item[0].'" style="font-size:20px;">
                    <input type="checkbox" name="complaint" value="'.$item[1].'" id="checkbox'.$item[0].'" data-toggle="checkbox">'
                        .$item[1].
                    '</label><br />';
    }
    echo '   </div>'.PHP_EOL;
    echo '</div>'.PHP_EOL;
    // The n-column table --------------------------------------------------


?>
     <br/>
            <input type="submit" name="submit" id="update" class="button button-orange" style="width: 90px; margin-top: 450px;
    margin-left: -1062px;" value="Update">
               <input type="submit" name="cancel" id="cancel" class="button button-orange" style="width: 90px; background-color:#36606e;" value="Cancel">

              <!-- <button class="button button-orange" ng-click="onClose()" style="width: 90px; background-color:#36606e;">Cancel</button>-->

                </form>

            </div>
        </div>

Question:

If a Main complaint item is select then that same complaint does not appear in Additional Complaint list (i.e. if 'complaint type 1' is selected for Main complaint, 'complaint type 1' does not display on Additional Complaint list)

How should I get that using one complaint.csv file like e.g on select 'complaint type 1', the data from complaint.csv file will be display on popup checkbox list except 'complaint type 1' which is selected?

Can anyone please suggest any solution?




Aucun commentaire:

Enregistrer un commentaire