Kanchan186

Kanchan186

Software Engineer at Pune

Member Since 3 Months Ago

Pune,Maharashtra

Experience Points
6,430
Total
Experience

3,570 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
5
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 2
6,430 XP
Nov
18
11 hours ago
Activity icon

Replied to Checkbox Shows Values Only ,'not Checkbox'

@nakov please check script , console.log(result); is correct?

Activity icon

Replied to Checkbox Shows Values Only ,'not Checkbox'

@nakov form that page i disable all css and js links still getting same error

Activity icon

Replied to Checkbox Shows Values Only ,'not Checkbox'

@snapey sir, i made changes , table replace with UL but no checkbox displayed

Activity icon

Started a new Conversation Checkbox Shows Values Only ,'not Checkbox'

view

    <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <h4 class="card-title">Add Mechanic Brands</h4>
                                <h6 class="card-subtitle"></h6>
                                @if ($errors->any())
                                <div class="alert alert-danger">
                                    <ul>
                                        @foreach ($errors->all() as $error)
                                            <li>{{ $error }}</li>
                                        @endforeach
                                    </ul>
                                </div>
                            @endif



                             



                               <form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data">
                                    {{csrf_field()}}

                                
                                      <div class="form-group">
                                        <h5>Segment<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($segment as $sg)
                                <ul><li>
                               <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id }}]" id="{{$sg->segment_id }}" onclick="getBrand1(this.id)" class="test">

                                <label  for="{{ $sg->segment_id }}">
                                <p>{{$sg->segment_name }}</p></label></li></ul>
                                
                                @endforeach
                                        </div>

                                       
                                    </div> 

                                    <div >
                                        <table id="brands" >
                                       

                                        </table>
                                   
                                     </div>

                              
                                               
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>
                                </div>
                                </div>
                            </div>
                        </div>

script

 <script type="text/javascript">

       function getBrand1(id)
   {
          //  alert('Choose brands!');

 if(document.getElementById(id).checked)  
   {  
       
       $.ajax({
        url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
       type: "GET",
       dataType: "json",
        error: function(data, errorThrown)
          {
              console.log('request failed :'+errorThrown);
          },
       success:function(result) {
         console.log(result);
        // alert(result);


                        $.each(result, function(index, value) { 
                        //alert(value); 
                        // $("#brands").html('<input type="checkbox" />'+value ); 
                        var markup = "<tr><td><input type='checkbox' style='border-color:#ff6677;width:200px;'></td><td>" + value + "</td></tr>";
                        $("#brands").append(markup);

                      });
                   }
              });
          }     
      
        else
            {
                $("#brands").html(""); 
            }
        

        }

</script>

controller


<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Mechanic;
use App\Segment;
use App\Brands;
use App\MechBrand;

class MechBrandController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }

    public function Add($mechanic_id)
    {
     

        $mechanic=Mechanic::findOrFail($mechanic_id);
    
    //  $mechanic_service_station_info=MechanicServiceStationInfo::get();
       $segment=Segment::get();
      $brand=Brands::get();
     
      $mech_brand=MechBrand::where('mech_brands.mechanic_id',$mechanic_id)->first();

        
        //dd($state);
        return view('backend.mechanic_brands.addMechBrands',compact('mechanic','brand','segment'));
    }

public function brandAjax($segment)
    {
      
        $brand=brands::where("segment_id",$segment)
                ->pluck('brand_name','brand_id')->all();
        return json_encode($brand);
    }
  
  public function store(Request $request)
    {
        
      foreach(request('sg') as $sg_id)
      {
         foreach(request('br') as $br_id)
              {

                $brands=Brands::where('brands.segment_id', $sg_id)->first();

                   if( $sg_id==$brands->segment_id)
                     
                           { 
                              MechBrand::create([
                             'mechanic_id'=>request('mechanic_id'),     
                             'active_status'=>1,
                             'segment_id'=>$sg_id,
                             'brand_id' => $br_id,
        
                            ]);
                         }
                    }
                 }
                 
      $mechanic=Mechanic::get();
        $segment=Segment::get();
        $brand=Brands::get();
        
        array($request->get('segment_id'));
        array($request->get('brand_id'));

      //dd('hi');
        //return 'Ok';
        return redirect('mechanic/view');
    }

}

from above screenshot , Add 989 shows on console.log(result);

Nov
11
1 week ago
Activity icon

Started a new Conversation Uncaught TypeError: Cannot Read Property 'querySelector' Of Null

view

<form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data">
                                    {{csrf_field()}}

                                
                                      <div class="form-group">
                                        <h5>Segment<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($segment as $sg)
                                <ul><li>
                               <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id }}]" id="{{$sg->segment_id }}" onclick="getBrand1(this.id)" class="test">

                                <label  for="{{ $sg->segment_id }}">
                                <p>{{$sg->segment_name }}</p></label></li></ul>
                                
                                @endforeach
                                        </div>

                                       
                                    </div> 

                    <div class="form-group">
                         <div class="controls">
                             <table id="brands">
                                <tr><td> 
                                    <tbody>           
                                    <input type="checkbox"  name="brand_id"></td></tr>
                                    </tbody>
                                    </table>
                            </div>
                         </div>

                         
                                    

         
                                               
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>

controller

public function brandAjax($segment)
    {
      
        $brand=brands::where("segment_id",$segment)
                ->pluck('brand_name','brand_id')->all();
        return json_encode($brand);
    }

script

<script type="text/javascript">

       function getBrand1(id)
   {
          //  alert('Choose brands!');

 if(document.getElementById(id).checked)  
   {  
       
       $.ajax({
        url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
       type: "GET",
       dataType: "json",
        error: function(data, errorThrown)
          {
              console.log('request failed :'+errorThrown);
          },
       success:function(result) {
         console.log(result);
        // alert(result);


                 /*       $.each(result, function(index, value) { 
                        //alert(value); 
                        // $("#brands").html('<input type="checkbox" />'+value ); 
                        var markup = "<tr><td><input type='checkbox' name='brand_id'></td><td>" + value + "</td></tr>";
                        $("#brands").append(markup);


                      }); */

                       $.each(result, function(index, value) { 
                        //alert(value); 
                        // $("#brands").html('<input type="checkbox" />'+value.brand_name ); 
                        var markup = "<tr><td><input type='checkbox' name='brand_id'></td><td>" + value.brand_name + "</td></tr>";
                        $("#brands").append(markup);

                      });



                   }
              });
          }     
      
        else
            {
                $("#brands").html(""); 
            }
        

        }

</script>

Activity icon

Replied to Checkboxes Are Not Displayed

@sinnbeck no sir i am not using tbody or thead

now values are displayed but without checkboxes i want values with checkboxes to check and store in database

Activity icon

Replied to Checkboxes Are Not Displayed

using this code output

and

on web page not showing values and checkboxes

Activity icon

Replied to Checkboxes Are Not Displayed

@sinnbeck after using this code nothing runs

$brand=brands::where("segment_id",$segment)
                ->pluck('brand_name','brand_id')->all()->values();
        return $brand;

shows error

request failed :error
blue.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)
Activity icon

Replied to Checkboxes Are Not Displayed

blue.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)

this error occurred but there is no CSS issue because other checkboxes runs properly

Activity icon

Replied to Checkboxes Are Not Displayed

it shows object

Activity icon

Replied to Checkboxes Are Not Displayed

yes sir it is array

controller

public function brandAjax($segment)
    {
      
        $brand=brands::where("segment_id",$segment)
                ->pluck('brand_name','brand_id')->all();
        return json_encode($brand);
    }
  
  public function store(Request $request)
    {
        
      foreach(request('sg') as $sg_id)
      {
         foreach(request('br') as $br_id)
              {

                $brands=Brands::where('brands.segment_id', $sg_id)->first();

                   if( $sg_id==$brands->segment_id)
                     
                           { 
                              MechBrand::create([
                             'mechanic_id'=>request('mechanic_id'),     
                             'active_status'=>1,
                             'segment_id'=>$sg_id,
                             'brand_id' => $br_id,
        
                            ]);
                         }
                    }
                 }
                 
      $mechanic=Mechanic::get();
        $segment=Segment::get();
        $brand=Brands::get();
        
        array($request->get('segment_id'));
        array($request->get('brand_id'));

      //dd('hi');
        //return 'Ok';
        return redirect('mechanic/view');
    }
Activity icon

Replied to Checkboxes Are Not Displayed

@jlrdw sir, i used it

 if(document.getElementById(id).checked)  
   {
      ...}
Activity icon

Started a new Conversation Checkboxes Are Not Displayed

view

<div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <h4 class="card-title">Add Mechanic Brands</h4>
                                <h6 class="card-subtitle"></h6>
                                @if ($errors->any())
                                <div class="alert alert-danger">
                                    <ul>
                                        @foreach ($errors->all() as $error)
                                            <li>{{ $error }}</li>
                                        @endforeach
                                    </ul>
                                </div>
                            @endif



                             



                               <form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data">
                                    {{csrf_field()}}

                                
                                      <div class="form-group">
                                        <h5>Segment<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($segment as $sg)
                                <ul><li>
                               <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id }}]" id="{{$sg->segment_id }}" onclick="getBrand1(this.id)" class="test">

                                <label  for="{{ $sg->segment_id }}">
                                <p>{{$sg->segment_name }}</p></label></li></ul>
                                
                                @endforeach
                                        </div>

                                       
                                    </div> 

                                   <div class="controls">
                                        <table id="brands">
                                        <tr><td>             
                               <input type="checkbox"  name="brand_id"></td></tr>

                                        </table>
                                   
                                     </div>

                         <!--    <div class="form-group">
                                <h5>Choose Brands<span class="text-danger">*</span></h5>
                                        <div class="controls" id="brands">
                                        <table>    
                                 <tr><td>             
                               <input type="checkbox"  name="brand_id"></td></tr>
                                        </div>
                                       
                                    </div> -->
                                    

                              
                                               
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>
                                </div>
                                </div>
                            </div>
                        </div>

script

<script type="text/javascript">

       function getBrand1(id)
   {
          //  alert('Choose brands!');

 if(document.getElementById(id).checked)  
   {  
       
       $.ajax({
        url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
       type: "GET",
       dataType: "json",
        error: function(data, errorThrown)
          {
              console.log('request failed :'+errorThrown);
          },
       success:function(result) {
         console.log(result);
        // alert(result);


                        $.each(result, function(index, value) { 
                        //alert(value); 
                        // $("#brands").html('<input type="checkbox" />'+value ); 
                        var markup = "<tr><td><input type='checkbox' name='brand_id'></td><td>" + value + "</td></tr>";
                        $("#brands").append(markup);

                      }); 
                   }
              });
          }     
      
        else
            {
                $("#brands").html(""); 
            }
        

        }
</script>
Activity icon

Replied to Uncaught TypeError: Cannot Read Property 'checked' Of Null At GetBrand1 (Add:967) At HTMLInputElement.onclick (Add:852) Blue.css:1 Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

@nakov

view

<div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <h4 class="card-title">Add Mechanic Brands</h4>
                                <h6 class="card-subtitle"></h6>
                                @if ($errors->any())
                                <div class="alert alert-danger">
                                    <ul>
                                        @foreach ($errors->all() as $error)
                                            <li>{{ $error }}</li>
                                        @endforeach
                                    </ul>
                                </div>
                            @endif



                             



                               <form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data">
                                    {{csrf_field()}}

                                
                                      <div class="form-group">
                                        <h5>Segment<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($segment as $sg)
                                <ul><li>
                               <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id }}]" id="{{$sg->segment_id }}" onclick="getBrand1(this.id)" class="test">

                                <label  for="{{ $sg->segment_id }}">
                                <p>{{$sg->segment_name }}</p></label></li></ul>
                                
                                @endforeach
                                        </div>

                                       
                                    </div> 

                                   <div class="controls">
                                        <table id="brands">
                                        <tr><td>             
                               <input type="checkbox"  name="brand_id"></td></tr>

                                        </table>
                                   
                                     </div>

                         <!--    <div class="form-group">
                                <h5>Choose Brands<span class="text-danger">*</span></h5>
                                        <div class="controls" id="brands">
                                        <table>    
                                 <tr><td>             
                               <input type="checkbox"  name="brand_id"></td></tr>
                                        </div>
                                       
                                    </div> -->
                                    

                              
                                               
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>
                                </div>
                                </div>
                            </div>
                        </div>

script

<script type="text/javascript">

       function getBrand1(id)
   {
          //  alert('Choose brands!');

 if(document.getElementById(id).checked)  
   {  
       
       $.ajax({
        url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
       type: "GET",
       dataType: "json",
        error: function(data, errorThrown)
          {
              console.log('request failed :'+errorThrown);
          },
       success:function(result) {
         console.log(result);
        // alert(result);


                        $.each(result, function(index, value) { 
                        //alert(value); 
                        // $("#brands").html('<input type="checkbox" />'+value ); 
                        var markup = "<tr><td><input type='checkbox' name='brand_id'></td><td>" + value + "</td></tr>";
                        $("#brands").append(markup);

                      }); 
                   }
              });
          }     
      
        else
            {
                $("#brands").html(""); 
            }
        

        }
</script>
Nov
08
1 week ago
Activity icon

Replied to Uncaught TypeError: Cannot Read Property 'checked' Of Null At GetBrand1 (Add:967) At HTMLInputElement.onclick (Add:852) Blue.css:1 Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

@nakov ,sir in network tab no url shows but in console shows error

Failed to load resource: the server responded with a status of 404 (Not Found)
/brand/Ajax/3:1 
Activity icon

Replied to Uncaught TypeError: Cannot Read Property 'checked' Of Null At GetBrand1 (Add:967) At HTMLInputElement.onclick (Add:852) Blue.css:1 Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

@nakov

after run thisyoursite.test/brand/Ajax/3 in new tab

This site can’t be reachedyoursite.test’s server IP address could not be found.
Search Google for yoursite test brand Ajax
ERR_NAME_NOT_RESOLVED
Activity icon

Replied to Uncaught TypeError: Cannot Read Property 'checked' Of Null At GetBrand1 (Add:967) At HTMLInputElement.onclick (Add:852) Blue.css:1 Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

web.php

//add Mechanic Brands
Route::get('mechanic_brands/{mechanic_id}/Add','[email protected]');
//save Mechanic_Service_station_info
Route::post('mechanic_brands/{mechanic_id}','[email protected]');
//get segment wise brand using ajax
Route::get('brand/Ajax/{segment}','[email protected]');

Activity icon

Replied to Uncaught TypeError: Cannot Read Property 'checked' Of Null At GetBrand1 (Add:967) At HTMLInputElement.onclick (Add:852) Blue.css:1 Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

@nakov sir i made changes according to you.. but same error occurs

Failed to load resource: the server responded with a status of 404 (Not Found)
/brand/Ajax/3:1 
Activity icon

Replied to Uncaught TypeError: Cannot Read Property 'checked' Of Null At GetBrand1 (Add:967) At HTMLInputElement.onclick (Add:852) Blue.css:1 Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

@nakov this line get error

    url: '/brand/Ajax/'+segment,

error

Uncaught ReferenceError: segment is not defined
    at getBrand1 (Add:970)
    at HTMLInputElement.onclick (Add:852)
blue.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)
Activity icon

Replied to Uncaught TypeError: Cannot Read Property 'checked' Of Null At GetBrand1 (Add:967) At HTMLInputElement.onclick (Add:852) Blue.css:1 Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

sir after replace with segment to id

this error occurred

Failed to load resource: the server responded with a status of 404 (Not Found)/brand/Ajax/3:1 
Activity icon

Replied to Uncaught TypeError: Cannot Read Property 'checked' Of Null At GetBrand1 (Add:967) At HTMLInputElement.onclick (Add:852) Blue.css:1 Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

@nakov

and function in controller,can i update like this?

public function brandAjax($id)
    {
      
        $brand=brands::where("segment_id",$segment)
                ->pluck('brand_name','brand_id')->all();
        return json_encode($brand);
    }
Activity icon

Replied to Uncaught TypeError: Cannot Read Property 'checked' Of Null At GetBrand1 (Add:967) At HTMLInputElement.onclick (Add:852) Blue.css:1 Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

controller

public function brandAjax($segment)
    {
      
        $brand=brands::where("segment_id",$segment)
                ->pluck('brand_name','brand_id')->all();
        return json_encode($brand);
    }
Activity icon

Replied to Uncaught TypeError: Cannot Read Property 'checked' Of Null At GetBrand1 (Add:967) At HTMLInputElement.onclick (Add:852) Blue.css:1 Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

@nakov now this error occured

Uncaught ReferenceError: segment is not defined
    at getBrand1 (Add:970)
    at HTMLInputElement.onclick (Add:852)
blue.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)
Activity icon

Replied to Uncaught TypeError: Cannot Read Property 'checked' Of Null At GetBrand1 (Add:967) At HTMLInputElement.onclick (Add:852) Blue.css:1 Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

view

<div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <h4 class="card-title">Add Mechanic Brands</h4>
                                <h6 class="card-subtitle"></h6>
                                @if ($errors->any())
                                <div class="alert alert-danger">
                                    <ul>
                                        @foreach ($errors->all() as $error)
                                            <li>{{ $error }}</li>
                                        @endforeach
                                    </ul>
                                </div>
                            @endif

                               <form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data">
                                    {{csrf_field()}}

                                
                                      <div class="form-group">
                                        <h5>Segment<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($segment as $sg)
                                <ul><li>
                               <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id }}]" id="{{$sg->segment_id }}" onclick="getBrand1(this)">

                                <label  for="{{ $sg->segment_id }}">
                                <p>{{$sg->segment_name }}</p></label></li></ul>
                                
                                @endforeach
                                        </div>

                                       
                                    </div> 

                                    <div class="controls"  id="brands">
                                   
                                     </div>

                              
                                               
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>
                                </div>
                                </div>
                            </div>
                        </div>

script

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
     <script type="text/javascript">

        function getBrand1(el)
   {
            alert('Choose brands!');

 if(el.checked)    {

       $.ajax({
       url: '/brand/Ajax/'+segment,
       type: "GET",
       dataType: "json",
       success:function(result) {
       data = eval(result);

       $.each(data, function(value,key){

       options += '<input type="checkbox" name="brand_id' + key + '" id="brand_id' + key + '"value="' + key + '" class="controls" />';

       options += '<label for="brand_id' + key + '">' + value + '</label>'; });
                       
       $("#brands").html(response); 

             }

         });
     }     

         else
            {
                $("#brands").html(""); 
            } 

        }

</script>
Activity icon

Replied to Uncaught TypeError: Cannot Read Property 'checked' Of Null At GetBrand1 (Add:967) At HTMLInputElement.onclick (Add:852) Blue.css:1 Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

now getting this error

Uncaught ReferenceError: segment is not defined
    at getBrand1 (Add:970)
    at HTMLInputElement.onclick (Add:852)
blue.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)
Activity icon

Started a new Conversation Uncaught TypeError: Cannot Read Property 'checked' Of Null At GetBrand1 (Add:967) At HTMLInputElement.onclick (Add:852) Blue.css:1 Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

view

<div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <h4 class="card-title">Add Mechanic Brands</h4>
                                <h6 class="card-subtitle"></h6>
                                @if ($errors->any())
                                <div class="alert alert-danger">
                                    <ul>
                                        @foreach ($errors->all() as $error)
                                            <li>{{ $error }}</li>
                                        @endforeach
                                    </ul>
                                </div>
                            @endif

                               <form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data">
                                    {{csrf_field()}}

                                
                                      <div class="form-group">
                                        <h5>Segment<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($segment as $sg)
                                <ul><li>
                                <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id }}]" id="{{$sg->segment_id }}" onclick="getBrand1()">

                                <label  for="{{ $sg->segment_id }}">
                                <p>{{$sg->segment_name }}</p></label></li></ul>
                                
                                @endforeach
                                        </div>

                                       
                                    </div> 

                                    <div class="controls"  id="brands">
                                   
                                     </div>

                              
                                               
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>
                                </div>
                                </div>
                            </div>
                        </div>

script

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
     <script type="text/javascript">

        function getBrand1()
   {
            alert('Choose brands!');

if(document.getElementById("segment_id").checked)
    {

       $.ajax({
       url: '/brand/Ajax/'+segment,
       type: "GET",
       dataType: "json",
       success:function(result) {
       data = eval(result);

       $.each(data, function(value,key){

       options += '<input type="checkbox" name="brand_id' + key + '" id="brand_id' + key + '"value="' + key + '" class="controls" />';

       options += '<label for="brand_id' + key + '">' + value + '</label>'; });
                       
       $("#brands").html(response); 

             }

         });
     }     

         else
            {
                $("#brands").html(""); 
            } 

        }

</script>

@stop

controlller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Mechanic;
use App\Segment;
use App\Brands;
use App\MechBrand;

class MechBrandController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }

    public function Add($mechanic_id)
    {
     

        $mechanic=Mechanic::findOrFail($mechanic_id);
    
    //  $mechanic_service_station_info=MechanicServiceStationInfo::get();
       $segment=Segment::get();
      $brand=Brands::get();
     
      $mech_brand=MechBrand::where('mech_brands.mechanic_id',$mechanic_id)->first();

        
        //dd($state);
        return view('backend.mechanic_brands.addMechBrands',compact('mechanic','brand','segment'));
    }

public function brandAjax($segment)
    {
      
        $brand=brands::where("segment_id",$segment)
                ->pluck('brand_name','brand_id')->all();
        return json_encode($brand);
    }
  
  public function store(Request $request)
    {
        
      foreach(request('sg') as $sg_id)
      {
         foreach(request('br') as $br_id)
              {

                $brands=Brands::where('brands.segment_id', $sg_id)->first();

                   if( $sg_id==$brands->segment_id)
                     
                           { 
                              MechBrand::create([
                             'mechanic_id'=>request('mechanic_id'),     
                             'active_status'=>1,
                             'segment_id'=>$sg_id,
                             'brand_id' => $br_id,
        
                            ]);
                         }
                    }
                 }
                 
      $mechanic=Mechanic::get();
        $segment=Segment::get();
        $brand=Brands::get();
        
        array($request->get('segment_id'));
        array($request->get('brand_id'));

            return redirect('mechanic/view');
    }
}

web.php


//get segment wise brand using ajax
Route::get('brand/Ajax/{segment}','[email protected]');
Nov
06
1 week ago
Activity icon

Replied to Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

view

 <form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data">
                                    {{csrf_field()}}

                                
                                      <div class="form-group">
                                        <h5>Segment<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($segment as $sg)
                                <ul><li>
                                <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id}}]" id="{{$sg->segment_id }}" onchange="getBrand(this.value)">

                                <label  for="{{ $sg->segment_id }}">
                                <p>{{$sg->segment_name }}</p></label></li></ul>
                                
                                @endforeach
                                        </div>

                                       
                                    </div> 


                               
                               <div id="brand"></div>
                                       
                                
                                     <!--  <div class="form-group">
                                        <h5>Brands<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($brand as $br)
                                <ul><li>
                                <input type="checkbox" name="br[{{$br->brand_id}}]" value ="{{$br->brand_id}}" id="{{$br->brand_id }}" class="test">

                                <label  for="{{ $br->brand_id }}">
                                <p><img src="{{url('/')}}/brand_logos/{{$br->brand_logo}}" width="70px" height="40px" /></p></label></li></ul>
                                
                                @endforeach
                                        </div>
                                       
                                    </div> -->

                                               
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>

script

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
                    <script type="text/javascript">
                     


                         
                    
                             function getBrand(segment)
                            {
                               if(segment) {
                                        $.ajax({
                                            url:url: '/brand/Ajax/'+segment,
                                            type: "GET",
                                            dataType: "json",
                                            success:function(result) {
                                                data = eval(result);
                                                var options = '';
                                        
                                                $.each(data, function(value,key){
                                     options += '<input type="checkbox" name="brand_id-' + key + '" id="brand_id-' + key + '" value="' + key + '" class="controls" />';
                                    options += '<label for="brand_id-' + key + '">' + value + '</label>';
                                  });

                                $('#brand').append(options);
                            }
                        });
                          return false;               
                        };

                       }  

 </script>  
Activity icon

Replied to Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

i made this changes..

but still getting error

Uncaught ReferenceError: getBrand is not defined
    at HTMLInputElement.onchange (Add:770)
blue.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)
Activity icon

Replied to Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

i updated my code

 <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id}}]" id="{{$sg->segment_id }}" onchange="getBrand(this.value)">
Activity icon

Replied to Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

@snapey after updating code.. error occur

Uncaught ReferenceError: getBrand is not defined
    at HTMLInputElement.onchange (Add:770)
blue.css:1 Failed to load resource: the server responded with a status of 404 (Not Found)
Activity icon

Replied to Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

this error occurred!

Uncaught ReferenceError: getBrand is not defined
    at HTMLInputElement.onchange (Add:770)
Activity icon

Started a new Conversation Uncaught TypeError: Cannot Read Property 'querySelector' Of Null

view

<form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data">
                                    {{csrf_field()}}

                                
                                      <div class="form-group">
                                        <h5>Segment<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($segment as $sg)
                                <ul><li>
                                <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id}}]" id="{{$sg->segment_id }}" onchange="getBrand(this.value)">

                                <label  for="{{ $sg->segment_id }}">
                                <p>{{$sg->segment_name }}</p></label></li></ul>
                                
                                @endforeach
                                        </div>

                                       
                                    </div> 


                               
                               <div id="brand"></div>
                                       
                                
                                     <!--  <div class="form-group">
                                        <h5>Brands<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($brand as $br)
                                <ul><li>
                                <input type="checkbox" name="br[{{$br->brand_id}}]" value ="{{$br->brand_id}}" id="{{$br->brand_id }}" class="test">

                                <label  for="{{ $br->brand_id }}">
                                <p><img src="{{url('/')}}/brand_logos/{{$br->brand_logo}}" width="70px" height="40px" /></p></label></li></ul>
                                
                                @endforeach
                                        </div>
                                       
                                    </div> -->

                                               
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>

script

 function getBrand(segment)
                            {
                               if(segment) {
                                        $.ajax({
                                            url: '{{url('/')}}/brand/Ajax/'+segment,
                                            type: "GET",
                                            dataType: "json",
                                            success:function(result) {
                                                data = eval(result);
                                                var options = '';
                                        
                                                $.each(data, function(value,key){
                                     options += '<input type="checkbox" name="brand_id-' + key + '" id="brand_id-' + key + '" value="' + key + '" class="controls" />';
                                    options += '<label for="brand_id-' + key + '">' + value + '</label>';
                                  });

                                $('#brand').append(options);
                            }
                        });
                          return false;               
                        };

                       }  

controller

public function brandAjax($segment)
    {
      
        $brand=brands::where("segment_id",$segment)
                    ->pluck('brands.brand_name,brands.brand_id')->all();
        return json_encode($brand);
    }

web.php

//get segment wise brand using ajax
Route::get('brand/Ajax/{segment}','[email protected]');
Activity icon

Started a new Conversation Failed To Load Resource: The Server Responded With A Status Of 404 (Not Found)

view

 <form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data">
                                    {{csrf_field()}}

                                
                                      <div class="form-group">
                                        <h5>Segment<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($segment as $sg)
                                <ul><li>
                                <input type="checkbox" value="sg[{{$sg->segment_id}}]" name="sport" id="{{$sg->segment_id }}" onchange="getBrands(this.value)" class="test">

                                <label  for="{{ $sg->segment_id }}">
                                <p>{{$sg->segment_name }}</p></label></li></ul>
                                
                                @endforeach
                                        </div>

                                       
                                    </div> 


                               
                               <div id="brand"></div>
                                       
                                
                                     <!--  <div class="form-group">
                                        <h5>Brands<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($brand as $br)
                                <ul><li>
                                <input type="checkbox" name="br[{{$br->brand_id}}]" value ="{{$br->brand_id}}" id="{{$br->brand_id }}" class="test">

                                <label  for="{{ $br->brand_id }}">
                                <p><img src="{{url('/')}}/brand_logos/{{$br->brand_logo}}" width="70px" height="40px" /></p></label></li></ul>
                                
                                @endforeach
                                        </div>
                                       
                                    </div> -->

                                               
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>

script

 function getBrand(segment)
                            {
                               if(segment) {
                                        $.ajax({
                                            url: '{{url('/')}}/brand/Ajax/'+segment,
                                            type: "GET",
                                            dataType: "json",
                                            success:function(result) {
                                                data = eval(result);
                                                var options = '';
                                        
                                                $.each(data, function(value,key){
                                     options += '<input type="checkbox" name="brand_id-' + key + '" id="brand_id-' + key + '" value="' + key + '" class="controls" />';
                                    options += '<label for="brand_id-' + key + '">' + value + '</label>';
                                  });

                                $('#brand').append(options);
                            }
                        });
                          return false;               
                        };

                       }  

controller

public function brandAjax($segment)
    {
      
        $brand=brands::where("segment_id",$segment)
                    ->pluck('brands.brand_name,brands.brand_id')->all();
        return json_encode($brand);
    }

web.php

//get segment wise brand using ajax
Route::get('brand/Ajax/{segment}','[email protected]');
Nov
05
1 week ago
Activity icon

Replied to When One Checkbox Is Checked Showing Its Related Checkboxes Using Jquery

segment contains two checbox

  1. two wheeler
  2. four wheeler

if i checked two wheeler then shows only two wheeler brands.. or if i checked four wheeler then shows only four wheeler brands.

brands also shows in checkbox type

this type of functioning i want