I am not Getting Any Errors but When i am trying to click on Form my form Type Mouse does not appear Ask Question

My form is Getting no Errors on Chrome Developers Error code but i am not getting and Text field or anything in my forms it is a very easy task but it had become a headache for me i will be very Helpfull if you help me with this

 <section class="reservation">
        <img class="img-responsive section-icon hidden-sm hidden-xs" src="{{ asset('frontend/images/icons/reserve_color.png') }}">
        <div class="wrapper">
            <div class="container-fluid">
                <div class=" section-content">
                    <div class="row">
                        <div class="col-md-5 col-sm-6">
                            <form class="reservation-form" method="post" action="{{ route('resrvation.reserve') }}">
                                      {{ csrf_field() }}

                                <div class="row">
                                    <div class="col-md-6 col-sm-6">

                                    <div class="form-group">
                                        <input type="text" class="form-control reserve-form empty iconified" name="name" id="name"
                                               placeholder="    Name">
                                    </div>
                                    <div class="form-group">
                                        <input type="email" name="email" class="form-control reserve-form empty iconified" id="email"  placeholder="    e-mail">
                                    </div>
                                </div>
                                <div class="col-md-6 col-sm-6">
                                    <div class="form-group">
                                        <input type="tel" class="form-control reserve-form empty iconified" name="phone" id="phone"  placeholder="    Phone">
                                    </div>
                                    <div class="form-group">
                                        <input type="text" class="form-control reserve-form empty iconified" name="dateandtime" id="datetimepicker1" placeholder="  Time">
                                    </div>
                                </div>
                                <div class="col-md-12 col-sm-12">
                                    <textarea type="text" name="message" class="form-control reserve-form empty iconified" id="message" rows="3"  placeholder="    We're listening"></textarea>
                                </div>
                                <div class="col-md-12 col-sm-12">
                                    <button type="submit" id="submit" name="submit" class="btn btn-reservation">
                                        <span><i class="fa fa-check-circle-o"></i></span>
                                        Make a reservation
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>

Laravel Javacript – Check if theme exists in session, add class Ask Question

I’m working on a system where the user can select a product and go to the next page. This product then gets saved in the session using laravel sessions. When the user decides to go to the next page and come back. The chosen product is indeed saved in the session, but the is no way for them to see what product they have chosen because the class isn’t applied to the product that was chosen.

The code may clarify it better:

@foreach($themes as $theme)
    <div class="col-md-4 mb-4">
        <div class="card theme-card card-hover depth-2 border-0" id="theme-id-{{$theme->id}}">
            <a href="" class="theme-link" data-toggle="modal" data-target="#theme{{ $theme->id }}">
               <div class="card-image" style="height: 200px; background-image: url('/uploads/{{ $theme->thumbnail }}'); background-size: cover; background-position: center center;"></div>
               <div class="card-body">
                    <div class="row">
                        <div class="col-md-2 vertical-center">
                            <i class="fab fa-magento fa-lg"></i>
                        </div>
                        <div class="col-md-10">
                            <p class="m-0">{!! str_limit($theme->name, $limit =  32, $end = '...') !!}</p>
                            <small class="text-muted">{{ $theme->productable_type }}</small>
                        </div>
                    </div>
                </div>
            </a>
            <div class="card-footer bg-white border-0 text-right pt-0">
                <div class="row">
                    <div class="col-md-6 text-left">
                        <input type="hidden" class="theme-name" name="theme[{{$theme->id}}]">
                        {{--<input type="hidden" value="{{ $theme->composer_package }}">--}}
                        <button data-card-id="{{$theme->id}}"  class="btn btn-orange btn-sm btn-theme-choice">Kiezen</button>
                    </div>
                    <div class="col-md-6 text-right">
                       <span style="font-size: 20px;" >€ {{ $theme->price }} EUR</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endforeach

In the above code, I for each trough every so-called “Theme” and I’m giving the ID of the theme as a data target and as ID. Then in my Javascript code, I do the following:

$('.btn-theme-choice').on('click', function (event) {

    event.preventDefault();
    newSelectedCardId = $(event.target).data('card-id');

    if(cardId === null) {
        cardId = newSelectedCardId;
    } else if (cardId !== newSelectedCardId) {
        $('#theme-id-' + cardId).removeClass('theme-chosen').find("input[name='theme["+cardId+"]']").val('');
        cardId = null;
    }

    var card = $('#theme-id-' + cardId );
    card.toggleClass('theme-chosen');
    selectedCardInput = card.find("input[name='theme["+cardId+"]']");

    if( !$('.theme-card').hasClass('theme-chosen') ) {
        selectedCardInput.val('');

    } else if ( $('.theme-card').hasClass('theme-chosen') ) {
        selectedCardInput.val('selected');
    }

    console.log(selectedCardInput);
});

Here I add the class to the card so the user can See which card they’ve selected. This choice then gets saved in the session using some PHP code in the controller

if( $theme == null ) {

    return redirect('plugins');

} elseif( $theme != null ) {

    foreach($this->predefinedArray as $value) {
        $request->session()->put('chosen_theme.' . $value, $theme->$value);
    }

    $request->session()->put('chosen_theme.composer_package', $theme->productable->composer_package);

    return redirect('plugins');
}

problem

How can I read the session and add the class to the card with the IDs that were stored in the session so if the person leaves the page and comes back, they can see what cards they’ve selected?

Thanks in advance

Javascript Search form not displaying when form input is cleared? Ask Question

If you go to http://app.collegeconnect.ph/sortsearch?sortby=HightoLow&rankingsortby=HightoLow&searchItem=&criteria=

Use the “Tuition Fees Range” filter (click any option, though I would recommend the first or second one), then click Apply Filter. You will see the search results AND the search form at the top.

Click “Clear” under the Tuition Fees Range filter and then click Apply Filter.

The search form at the top disappears and you just see the buttons that control the forms.

Chrome console shows the following errors:

Uncaught SyntaxError: Unexpected token ,
Uncaught ReferenceError: openCity is not defined
at HTMLButtonElement.onclick (sortsearch?sortby=HightoLow&rankingsortby=HightoLow&searchItem=&criteria=:92)
at sortsearch?sortby=HightoLow&rankingsortby=HightoLow&searchItem=&criteria=:1495
Uncaught SyntaxError: Unexpected token }

Basically, a person MUST select an option under the Tuition Fees Range filter in order for the the search form to show. Not sure how get the search form to show even if the filter is cleared and a person uses the other filters.

Here’s the code for the searchController: https://paste.ee/p/jE6DR

the blade file: https://paste.ee/p/5pY7W

Error dynamically updating a table row using ajax Ask Question

I am trying to update the value (views) of a table row using Ajax when an onclick event is called.

The views are updated but the problem is that I can’t get the new value of the views to show on that particular table row.

I have to refresh the page to see the updated views value and that’s not what I want.

I want it updated dynamically as the button is clicked. This is what I am doing.

<table>
@foreach($data as $datum)
<tr>
  <td><span class="view2">{{$datum->views}}</span></td>
  <td><button class="btn btn-default" onclick="bigImg(event)"  value="{{$datum->game_id}}">click</button></td>
 </tr>
@endforeach                                         
</table>
<script>
        function bigImg(event) {
            var game_id = event.target.value;
            var obj = $(this);
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                },
                type:'POST',
                dataType:'JSON',
                url:'{{url('views')}}',
                data:'game_id='+game_id,
                success:function(data)
                {
                    var data=eval(data);
                    message=data.message;
                    //console.log(message);
                    obj.closest('tr').find(".view2").text(message);
                }
            });
        }
    </script>

Show posts with ajax – Use of undefined constant postObj – assumed 'postObj' Ask Question

I have a homepage where there is a menu with some categories and below there are the latest posts:

<ul class="Categories__Menu"> 
    @foreach($categories->take(6) as $category)
        <li class="ative">
            <a href="" name="category" id="{{$category->id}}">{{$category->name}}</a>
        </li>
    @endforeach
</ul>

<div class="row" id="posts">
 @foreach($posts as $post)
<div class="col-12 col-sm-6 col-lg-4 col-xl-3 mb-4">
    <div class="card">
        <img class="card-img-top" src="{{$post->image}}" alt="Card image cap">
        <h5 class="card-title">{{$post->name}}</h5>
        <div class="card-footer d-flex justify-content-between align-items-center">
            <a href="{{route('posts.show', ['id' => $post->id, 'slug' => $post->slug])}}" class="btn btn-primary text-white">More</a>
        </div>
    </div>
</div>
@endforeach
</div>

I want that when each category is clicked to show only the posts of that category in the homepage, but in the same homepage, not in a specific category page.

So I have this Ajax:

$(function() {
    $("a[name='category']").on('click', function(){
        var category_id = $(this).attr("id");
        $.ajax({
            url: '{{ route('category.posts',null) }}/' + category_id,
            type: 'GET',
            success:function(result){

                $('#posts').empty();
                $.each(result,function(index, postObj){
                    $('#posts').append("<p>"+postObj.name+"</p>");
                });
                console.log(result);
            },
            error: function(error) {
                console.log(error.status)
            }
        });

    });
});

And its working fine, but instead of show just this:

                $('#posts').append("<p>"+postObj.name+"</p>");

I want to show the posts with the real html above like:

<div class="col-12 col-sm-6 col-lg-4 col-xl-3 mb-4">
        <div class="card">
            <img class="card-img-top" src="{{$post->image}}" alt="Card image cap">
            <h5 class="card-title">{{$post->name}}</h5>
            <div class="card-footer d-flex justify-content-between align-items-center">
                <a href="{{route('posts.show', ['id' => $post->id, 'slug' => $post->slug])}}" class="btn btn-primary text-white">More</a>
            </div>
        </div>
    </div>

So Im using like this in ajax:

$("a[name='category']").on('click', function(){

                var category_id = $(this).attr("id");
                alert(category_id);

                $.ajax({

                    url: '{{ route('category.posts',null) }}/' + category_id,
                    type: 'GET',
                    success:function(result){

                        $('#posts').empty();
                        $.each(result,function(index, postObj){
                            //$('#posts').append("<p>"+postObj.name+"</p>");
                            $('#posts').append("<div class="col-12 col-sm-6 col-lg-4 col-xl-3 mb-4">n" +
    "                        <div class="card box-shaddow">n" +
    "                            <img class="card-img-top" src="{{postObj.image}}" alt="Card image cap">n" +
    "                                <h5 class="card-title h6 font-weight-bold text-heading-blue">{{postObj.name}}</h5>n" +
    "                            <div class="card-footer d-flex justify-content-between align-items-center">n" +
    "n" +
    "                                <a href="{{route('posts.show', ['id' => postObj.id, 'slug' => postObj.slug])}}" class="btn btn-primary text-white">More</a>n" +
    "                            </div>n" +
    "                        </div>n" +
    "                    </div>");
                        });
                        console.log(result);
                    },
                    error: function(error) {
                        console.log(error.status)
                    }
                });

            });

But it appears an error:

Use of undefined constant postObj - assumed 'postObj'

Do you know why?

PostController:

public function WhereHasCategory(Request $request)
    {
        $posts = Post::whereHas('categories', function ($categories) use (&$request) {
            $categories->where('id',$request->id);
        })->get();

        return response()->json($posts);
    }

Route to the ajax part:

Route::get('posts/where/category/{id}','PostController@WhereHasCategory')->name('category.posts');

Method to return the homepage view:

public function index(){
        return view('home')
            ->with('categories', Category::orderBy('created_at', 'desc')->get())
            ->with('posts', Post::orderBy('created_at','desc')->take(8)->get());
    }

algolia Instantsearchjs how to display and search using <Searchbox> globally on an ecommerce website Ask Question

Im using instantsearch.js , my website is an ecommerce application in laravel and algolia is working perfect on hits page.

enter image description here

My main question is how can I implement SearchBox in other webpages (home, static, etc) allowing people to write on header searchbox and when they press enter -> be forwarded to my search results page (eg: www.example.com/search/query?q=apple)

Taking into consideration Im using instantsearch.js completely, my controller and routes in laravel are not passing any variable into that view.

thanks in advance.

Adicionar e remover elementos no array Ask Question

tenho um form com 60 input textbox com name numero[], desses 60 números só poderei selecionar uma quantidade x( quantidade pode ser variável ); como faço para quando o usuário desmarcar o checkbox o numero seja removido do array ?

var i=0,selecionados=[], maximo = {{ $dados->numeros }}, input=0;

    Array.prototype.remove = function() {
	    var what, a = arguments, L = a.length, ax;
	    while (L && this.length) {
	        what = a[--L];
	        while ((ax = this.indexOf(what)) !== -1) {
	            this.splice(ax, 1);
	        }
	    }
	    return this;
	};
	 
    //***************************************************************

 	function selecione(valor){

 		selecionados.push(valor);

 		for (i = 1; i < selecionados.length; i++) {
 			if(selecionados[valor] == valor){
 				selecionados.remove(''+valor);
 				alert('ok');
 				console.clear();
 				console.log(selecionados);
 			}
 		}

 		console.log(selecionados);
 		
	}
<div class="container-fluid">
	<form name="form" action="{{ route('aposta.salvar')}}" method="POST">
		
		<input type="hidden" name="numeros" value="{{ $dados->numeros }}">
		<input type="hidden" name="cotacao" value="{{ $dados->cotacao }}">
		@for ($i = 1; $i < 61; $i++)
			<div class="col-md-1" >
					<input type="checkbox" onclick="selecione({{$i}})" id="{{$i}}" name="numero[]" value="{{ ($i < 10) ? (0 . $i) : $i }}" />				
				<div class="box box-primary checkbox" id="box-{{ $i }}" type="checkbox" >
	               	<div class="box-body box-profile">
						<h5 class="text-center">{{ ($i < 10) ? (0 . $i) : $i }}</h5>
					</div>
				</div>
			</div>			
		@endfor			

		<div class="btn-inline">
		    <a href="#" onClick="history.go(0)" class="btn btn-warning ">Limpar</a>
		    <a href="#" onclick="gerar()" class="btn btn-danger">Gerar</a>
		    <button type="submit" class="btn btn-primary  btn-flat">Proximo</button>
		</div>
	</form>
</div>

Want to update active status from 1 to 0 using ajax Ask Question

I am going to enabled or disable a button depending on the status of the value of column ‘active’ in database. And I want to change the button status using javascript or ajax. And ‘active’ value in database should also be updated.

blade.php

                                 <td class="text-center">
                                     <a href="#" data-toggle="modal" data-target="#myModal" class="edit"><i class="fa fa-comment"></i></a>
                                     @if( $joins->active == "1")
                                         <a href="{{route('asset.status',$joins->id)}}" id="return" data-toggle="modal" @if($joins->active === "1") class="edit  action-button" @else class="disabled2" @endif><i class="fa fa-get-pocket"></i></a>
                                     {{--@else--}}
                                     {{--<a href="#" id="return" data-toggle="modal" class="disabled2"><i class="fa fa-get-pocket"></i></a>--}}

                                     @endif
                                 </td>

script

<script>
    $(".action-button").click(function(){
        swal({
            type : 'warning',
            title: 'Submit what you want',
            input: 'text',
            showCancelButton: false,
            confirmButtonText: 'Submit',
            showLoaderOnConfirm: true,
            allowOutsideClick: false

        }).$.ajax({
        type: "POST",
        url : 'profile-management/employee-assets/update/{id}',
        data: { id: id },
        success: function(data){
            swal('Confirmed!','success')
        }

        });
    })

</script>

web.php

Route::get('profile-management/employee-assets/update/{id}','AssetController@statusUpdate')->name('asset.status');

Controller.php

   public function statusUpdate(Request $request,$id){
        $update = Asset::find($id);
        $update->active = "1";

        $update->save();
        $request->session()->flash('alert-info', 'Product Status Updated!');
        return redirect('/profile-management/employee-assets');
    }

I want to filter one dropdown list depending on another dropdown Ask Question

I have departments on one side and employees on another side. I want to filter employees depending on the selection of departments. I am not good in javascipt or ajax.

            <div class="pure-checkbox ml-15">
               <input id="checkbox2" name="stars" type="radio" data-type="round" class="checkbox look-me" value="2">
               <label for="checkbox2"> Department </label>
            </div>
            <div id="show-me-three">
               <select class="form-control e1">
                   <option>Select</option>
               @foreach($department as $departments)
                       <option>{{ $departments->Name }}</option>
                   @endforeach
               </select>

            <div class="pure-checkbox ml-15 asset-employee-checkbox">
               <input id="checkbox6" name="stars" type="checkbox" data-type="round" class="checkbox" value="6">
               <label for="checkbox6">Employee</label>
            </div>
            <div class="asset-employee-list-show">
               <select class="form-control e1" name="ename">
                   <option>Select</option>
                       @foreach($all as $alls)
                           <option>{{ $alls->username }}</option>
                       @endforeach
               </select>
            </div>
            </div>