How to display input values ​on certain categories of elements

49 views Asked by At

I have following divs and I am using onclick="javascript:window.print();" to print the inputs of these divs. And in my database, I have 3 categories of agents. But I would like these inputs bellow:

         <label for="exampleInputEmail1"><?php echo lang('name'); ?></label>
       <div class="case_patient"></div>
     </div>
     <div class="form-group col-md-6 case_patient_block" style="display: none">
       <label for="exampleInputEmail1"><?php echo lang('phone'); ?></label>
     <div class="case_patient"></div>
  </div>
   <div class="form-group col-md-6 case_patient_block" style="display: none">
    <label for="exampleInputEmail1"><?php echo lang('company'); ?></label>
   <div class="case_patient"></div>
</div>

are only printed if the category is Personal, otherwise, only the other entries are printed and this without using JavaScript since I am not good at JavaScript.

This is the code:

    <div class="modal fade" id="caseModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close no-print" data-dismiss="modal" aria-hidden="true">×</button>
                        <h4 class="modal-title"><?php echo lang('details'); ?>  <?php echo lang('case'); ?> </h4>  
                    </div>
                    <div class="modal-body row">
                        <form role="form" id="medical_historyEditForm" class="clearfix" action="patient/addMedicalHistory" method="post" enctype="multipart/form-data">
                            <div class="form-group col-md-12 row">
        
                                <div class="panel col-md-12" style="text-align: center">
                                    <h3> <?php echo lang('hospital'); ?> <?php echo $settings->title ?></h3><img alt="" src="<?php echo $this->settings_model->getSettings()->logo; ?>" width="200" height="100">
                                    <h5><?php echo $settings->address; ?></h5>
                                </div>
        
                                <div class="form-group col-md-12 case_patient_block">
                                    <label for="exampleInputEmail1"><?php echo lang('patient'); ?></label>
                                    <div class="case_patient"></div>
                                    <div class="case_patient_id"></div>
                                </div> 
        
                                <div class="form-group col-md-6 case_patient_block" style="display: none">
                                    <label for="exampleInputEmail1"><?php echo lang('name'); ?></label>
                                    <div class="case_patient"></div>
                                </div>
        
                         <div class="form-group col-md-6 case_patient_block" style="display: none">
          <label for="exampleInputEmail1" value="if($pCategory=="Personnel")><?php echo lang('phone'); ?></label>
                                    <div class="case_patient"></div>
                                </div>
        
                         <div class="form-group col-md-6 case_patient_block" style="display: none">
                          <label for="exampleInputEmail1" value="if($pCategory=="Personnel") ">
                            <?php echo lang('company'); ?></label>
                           <div class="case_patient"></div>
                                </div>
        
        
                                <div class="form-group col-md-4">
                                    <label><?php echo lang('age'); ?></label>
                                    <div class="ageClass"></div>     
                                </div>
                                <div class="form-group col-md-6 case_patient_block">
                                    <label for="exampleInputEmail1"> <?php echo lang('birth_date'); ?></label>
                                    <div><?php echo $patient->birthdate; ?></div>
                                </div>
        
        
                                <div class="form-group col-md-6 case_date_block">
                                    <label for="exampleInputEmail1"><?php echo lang('date'); ?> de <?php echo lang('case'); ?></label>
                                    <div class="case_date"></div>
                                </div>
                                <div class="form-group col-md-4">
                                    <label for="exampleInputEmail1"><?php echo lang('address'); ?></label>
                                    <div class="addressClass"></div>
                                </div>
                                <div>
                                    <hr>
                                </div>
                            </div>
        
       <div class="form-group col-md-12">
        <label for="exampleInputEmail1"><?php echo lang('title'); ?> </label>
       <div class="case_title"></div>
                                
                            </div>
      <div class="form-group col-md-12">
       <label for="exampleInputEmail1"> <?php echo lang('details'); ?></label>
     <div class="case_details"></div>
    
    <div class="panel col-md-12 no-print">
      <a class="btn btn-info invoice_button pull-right" onclick="javascript:window.print();"><i class="fa fa-print"></i> <?php echo lang('print'); ?> </a>
     </div>
        
    </form>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div>
    
    <style>
    
        @media print {
    
            .modal-content{
                width: 100%;
            }
   
            .modal{
                overflow: hidden;
            }
    
            .case_date_block{
                width: 50%;
                float: left;
            }
    
            .case_patient_block{
                width: 50%;
                float: left;
            }
        }
    </style>

I tried to put an if() in value so that if the page to print is from the patient in the Personal category then the input is listed among the elements to print

1

There are 1 answers

1
Paarth Pratim Mout On

As I understand you only want the div's with phone and company displayed in the browser when the "pCategory" value is "Personnel". If this is the case, then your code syntax is wrong. Perhaps you should consider including the divs inside an "if" statement like this:

<?php 
if($pCategory=="Personnel"){
    ?>
    <div class="form-group col-md-6 case_patient_block">
        <label for="exampleInputEmail1"><?php echo lang('phone'); ?></label>
        <div class="case_patient"></div>
    </div>

    <div class="form-group col-md-6 case_patient_block">
        <label for="exampleInputEmail1"><?php echo lang('company'); ?></label>
        <div class="case_patient"></div>
    </div>
    <?php
}

?>

Also, the label tag does not contain "value" attribute so you should remove it, and if you are trying to use these div's as input consider using input html tags instead of label.

Also in the above code, the inline css where display is set to none is also removed in order to display the divs.