Not showing inside console window and network tab - html

The second part is the html code and the first part is the angularjs part .
customer.controller("new_info",
function($scope, $routeParams,$http)
{
$scope.customer = {};
$scope.register = function () {
$http.post('localhost:4000/new_info', $scope.customer).then(
function (response) {
console.log("posted successfully"); //not showing anything in the console window
}
);
}
});
<div class="col-md-6">
<div class="panel-body">
<form name="AddCustomer" >
<div class="form-group">
<label>Id</label>
<input type="text" class="form-control" ng-model="customer.id" />
</div>
<div class="form-group">
<label>Name</label>
<input type="text" class="form-control" ng-model="customer.name" />
</div>
<div class="form-group">
<label>City</label>
<input type="text" class="form-control" ng-model="customer.city" />
</div>
<button class="btn btn-default" ng-click="register()">Submit</button>
</form>
</div>
</div>
//after clicking the button its not showing anything .

Related

Html Form not passing image file name to laravel controller

Laravel Blade Form not passing image . it comes out null but other types are passed.
this is the form;
<div class="modal-body">
<form method="POST" action="{{route('slide.store')}}" enctype="multipart/form-data">
#csrf
<div class="form-group">
<label for="name">Title</label>
<input type="text" class="form-control" placeholder="Enter Slide Title" name="name">
</div>
<div class="form-group">
<label for="name">Description</label>
<input type="text" class="form-control" placeholder="Enter Slide Description" name="description">
</div>
<div class="form-group">
<label for="name" >Image</label>
<input type="file" name="image">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<input type="submit" class="btn btn-primary" name="submit">Save</button>
</div>
</form>
</div>
this is the controller store function;
public function store(Request $request)
{
return $request->all();
$product = New Slide($request->except(['image']));
$product->save();
//store image
if($request->hasFile('image') && $request->file('image')->isValid()){
$product->addMediaFromRequest('image')->toMediaCollection('images/slides');
}
return redirect("slide/index/{$product->id}")->with('success', 'New Slide Added.');
}
and this is the route;
Route::resource('slide', 'SlideController');
I have included the enctype="multipart/form-data" already. I cant see what am doing wrong. Any help will be appreciated.

How to store data to browser cache directory in html?

The Project: https://github.com/marcosnunes/storeData
I need to publish into {div id="result"}{/div} the data from the form and then store to local cached directory. Would anyone help me to write this code? What I am trying to do is make a local site for to be loaded into an Android Hibrid App.
The form:
<body>
<div class="w3-container">
<div class="w3-card-4" style="width:100%">
<header class="w3-container w3-light-grey">
<h2><Div id="nameBox"></Div></h2>
</header>
<div class="w3-container">
<h2><div id="result"></div></h2>
</div>
</div>
</div>
<div class="w3-container">
<div class="row">
<div class="col-md-8">
<h3>Adicionar um Envelope e Saldo</h3>
<form name="contact-form"
method="post" id="contact-form">
<div class="form-group">
<label for="inputName">Envelope</label>
<input type="text"
class="form-control" id="cardName" name="cardName" placeholder="Envelope"
required>
</div>
<div class="form-group">
<label for="inputValue">Valor</label>
<input type="number" class="form-control" id="Value" name="Value"
placeholder="Valor" required>
</div>
<div class="form-group">
<label for="inputDescription">Descrição</label>
<input type="text" class="form-control" id="Description"
name="Description"
placeholder="Descrição" required>
</div>
<button onclick="store()" class="btn btn-primary" name="submit"
value="Submit"
id="submit_form">Adicionar</button>
</form>
</div>
</div>
</div>
</body>
</html>
I need too create new div on the button onclick()
The java code
<script>
function store(){
if (typeof(Storage) !== "undefined") {
var inputName = document.getElementById("cardName");
sessionStorage.setItem("cardName", inputName.value);
var inputValue = document.getElementById("Value");
sessionStorage.setItem("Value", inputValue.value);
var inputDescription = document.getElementById("Description");
sessionStorage.setItem("Description", inputDescription.value);
document.getElementById("result1").innerHTML = sessionStorage.getItem("cardName");
document.getElementById("result2").innerHTML = sessionStorage.getItem("Value");
document.getElementById("result3").innerHTML = sessionStorage.getItem("Description");
} else {
document.getElementById("result").innerHTML = "Ops! Alguma coisa deu errado...";
}
}
I got it !
Just inserted type="button" on button.
<button onclick="store()" **type="button"** class="btn btn-primary"
name="submit" value="Submit"
id="submit_form">Adicionar</button>

How refresh part of page after submit?

I develop function for create user, when I create user all the page refresh,but i want just the tables refrech automatically, just the table refresh and not all the page, how to correct my problem ?
function JSalert() {
swal({
title: "opération effectuée avec succès",
text: "",
icon: "success",
confirmButtonColor: "#C13232"
});
$(document).ready(function() {
$("button").click(function() {
location.reload(true);
});
});
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="modal-body" ng-style="{'height': '500px','width':'643px'}">
<form name="myForm1" id="myForm">
<div class="form-group">
<label name="refe" class="col-form-label">Email:</label><span style="color: red;">*</span>
<input type="text" class="form-control" name="refee" ng-model="registration.Email" required>
</div>
<div class="form-group">
<label id="tire7" class="col-form-label">Adress:</label><span style="color: red">*</span>
<input type="text" class="form-control" name="titree" ng-model="registration.Adress" required>
</div>
<div class="form-group">
<label id="tire75" class="col-form-label">Mobile:</label><span style="color: red">*</span>
<input type="text" class="form-control" name="titree" ng-model="registration.Mobile" required>
</div>
<div class="form-group">
<label id="site" class="col-form-label">Site:</label><span style="color: red">*</span>
<input type="text" class="form-control" name="titre12" ng-model="registration.Site" required>
</div>
</form>
</div>
<button type="button" class="btn btn-primary" id="btnsave" data-dismiss="modal" onclick="JSalert()" ng-click="signUp()" style="margin-left: 350px" disabled>Done
</button>
For refreshing only particular table without reloading page, call the service(for the data that you are displaying in the table) once again after success signup.

ng-click is not sending value to the angular controller

I have a form and trying to send the value of the input to the angular controller but on click, the value in the controller is showing undefined.
html code
<div ng-if="questioncode == 2" class="user-form">
<div class="row">
<form>
<div class="col-sm-12">
<label class="control-label" >Phone number</label>
</div>
<div class="col-sm-12">
<input type="text" class="form-control" name="phone" placeholder="your phone number" ng-model="phone">
</div>
<div class="col-sm-12">
<input type="submit" class=" col-sm-12 btn btn-primary" ng-click="submituserPhone();" >
<flash-message duration="3000" show-close="true" on-dismiss="myCallback(flash);" ></flash-message>
</div>
</form>
</div>
</div>
angular controller
$scope.submituserPhone = function() {
console.log($scope.phone);
$http.post('insertphone',$scope.phone),then(function() {
if(response.data.status === false) {
Flash.create('danger',response.data.message);
}else{
$scope.questioncode = 3;
}
})
}
So the problem is the ng-if which is creating a new scope, hence the scope variable phone is not getting updated in the controller. Here are two methods to tackle this problem.
Using $parent:
You can use $parent to update the variable of the parent scope instead of the current one, then your variable will be visible inside the controller.
var app = angular.module('myApp', []);
app.controller('MyController', function MyController($scope) {
$scope.questioncode = 2;
$scope.submituserPhone = function() {
console.log($scope.phone);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-controller='MyController' ng-app="myApp">
<div ng-if="questioncode == 2" class="user-form">
<div class="row">
<form>
<div class="col-sm-12">
<label class="control-label">Phone number</label>
</div>
<div class="col-sm-12">
<input type="text" class="form-control" name="phone" placeholder="your phone number" ng-model="$parent.phone">
</div>
<div class="col-sm-12">
<input type="submit" class=" col-sm-12 btn btn-primary" ng-click="submituserPhone();">
<flash-message duration="3000" show-close="true" on-dismiss="myCallback(flash);"></flash-message>
</div>
</form>
</div>
</div>
</div>
Pass the variable as a parameter:
You can simply just pass the variable of the created scope into the controller function and update it there, as shown below.
var app = angular.module('myApp', []);
app.controller('MyController', function MyController($scope) {
$scope.questioncode = 2;
$scope.submituserPhone = function(phone) {
$scope.phone = phone;
console.log($scope.phone);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-controller='MyController' ng-app="myApp">
<div ng-if="questioncode == 2" class="user-form">
<div class="row">
<form>
<div class="col-sm-12">
<label class="control-label">Phone number</label>
</div>
<div class="col-sm-12">
<input type="text" class="form-control" name="phone" placeholder="your phone number" ng-model="phone">
</div>
<div class="col-sm-12">
<input type="submit" class=" col-sm-12 btn btn-primary" ng-click="submituserPhone(phone);">
<flash-message duration="3000" show-close="true" on-dismiss="myCallback(flash);"></flash-message>
</div>
</form>
</div>
</div>
</div>

data not updating on laravel 5.4?

Here is my edit.blade file.Please notice on From tag action attribute.Is this Ok?
#extends('admin_theme.master')
#section('title','Add Category')
#section('content')
#if(Auth::check())
<script>
function validselect(){
var ind=document.getElementById('my_select').selectedIndex;
if(ind==0){
alert("please select an Valid Option");
}
}
</script>
<div class="forms">
<div class=" form-grids form-grids-right">
<div class="widget-shadow " data-example-id="basic-forms">
<div class="form-title">
<h4>Ready To ADD:</h4>
</div>
<div class="form-body">
<form class="form-horizontal" action={{route('category.update',$singledata->id)}} method="put">
{{ csrf_field() }}
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Category Name</label>
<div class="col-sm-9">
<input class="form-control" id="inputEmail3" placeholder="Name" type="text" value="{{$singledata->name}}" name="name">
</div>
</div>
<div class="form-group">
<label for="inputPassword3" class="col-sm-2 control-label">Status</label>
<div class="col-sm-9">
<Select class="form-control" id="my_select"onchange="validselect()" name="status">
<option>Select availability</option>
<option value="1" #if($singledata->status==1){{"selected"}} #endif >Active</option>
<option value="0" #if($singledata->status==0){{"selected"}} #endif>DeActive</option>
</Select>
</div>
</div>
<div class="form-group">
</div>
<div class="col-sm-offset-2"> <button type="submit" class="btn btn-default" >Update</button>
</div>
</form>
</div>
</div>
</div>
</div>
#endif
#endsection
Here is my update method in controller and here the inputted data from edit page not found in $request object.I changed the html method like as PUT or PATCH but no luck :)
public function update(Request $request, $id)
{
$allinput=$request->all();
// dd($allinput);
// dd($allinput);
$data=Category::findorfail($id);
$data->update($allinput);
return view('admin_theme.dynamic_files.category.allCategory');
}
here is my route
<?php
Route::get('/', function () {
return view('my_theme.index');
});
Auth::routes();
Route::get('/admin', 'HomeController#index');
Route::resource('category','CategoryController');
In before (doing CRUD) the store() method works fine the problem is when i update data...i am stuck on this,please help me on this.Thanks in advance
Atlast solved
adding method="POST" in form tag and also add below line after {{csrf_field()}}
<input name="_method" type="hidden" value="PATCH">
but why this line need ?dont know.If anyone make me understand i will be thankfull :)