php - How to run javascript code when table design is in controller of laravel 5.4 -


i have table design in controller of laravel.

it populated in form designed in blade via ajax call.

my table looks this:

if(count($sublaw_details)>0)                 {                     $res_div.='<table width="100%" border="0"  class="table table-striped table-bordered table-hover">';                     $res_div.='<tr>                                     <td colspan="2" rowspan="2">                                         <strong>'.$law_details->lm_id.' ('.$law_details->law_name.')</strong>                                     </td>                                     <td >                                         <span class="required" aria-required="true">* </span><input type="text" value="'.$start_date.'" placeholder="dd-mm-yyyy (start date)" onchange="showdata();" name="law_start_date[]" id="law_start_date" att_law_id="'.$lawdata[$i].'"  class="date-picker required locationformstyle locationparentsd dynamiclocationparentsd'.$lawdata[$i].'">                                         <span class="error" style="visibility: visible" id="er"  name="er">required</span>                                                                          </td>                                 </tr>                               <tr>                               <td>                                         <span class="required" aria-required="true">* </span><input type="text" placeholder="law registration no." name="law_reg_no" id="law_reg_no" class="locationformstyle required">                               </td>                               </tr>';                      foreach($sublaw_details $sublawdetails)                     {                         if (in_array($sublawdetails->sublaw_id, $sublawdata))                         {                             $res_div.='<tr>             <td width="220">start date: <input type="text" name="sub_law_start_date[]" placeholder="dd-mm-yyyy" onfocus="this.blur()" class="locationformstyle date-picker dynamiclocationparentsd'.$lawdata[$i].'" att_law_id="'.$lawdata[$i].'"> </td>             <td width="220">end date: <input type="text"  name="sub_law_end_date[]" placeholder="dd-mm-yyyy" onfocus="this.blur()" class="locationformstyle date-picker"></td>             <td align="left"><strong>'.$sublawdetails->lms_id.' ('.$sublawdetails->sub_law_name.')</strong>             <input type="hidden" class="locationformstyle" name="company_sub_laws[]" value="'.$sublawdetails->sublaw_id.'">             </td>             </tr>             ';                         }                     }                     $res_div.='</table>';                 } 

i want hide span when start date selected

here javascript code have written.

<script> function showdata() {        document.getelementbyid("er").style.visibility = "hidden";  } </script>  

first thing controller not creating views. routing or communicator between views , database layers.

here change controller:

  • create new view lets table.blade.php.
  • in controller add below statements

    $tableviewinstring = view('table',array_of_parameters)->__tostring();

  • return string view response ajax call.

if using jquery suggest following way it.

$(".date").datepicker({   onselect: function(datetext) {         $("#idofspan").hide();     } }); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -