Select value null after form submission - html

I have a form in which i toggle 'input text> with <select> using radio buttons. The problem is, i get the result back correctly when user enters value in <input text> but not with <select>.
Basically i'm sending searchType(the radio buttons that selects either the <input text> or the select) and searchKey(the values of <input text> or the select). When i use the <input text> the values are transferred after form submission whereas no values are transferred using select although the name is same for both. i.e searchKey
Can anyone please point out the fault in the code?
<div class="well">
<form class="form-horizontal" action="<%=request.getContextPath()%>/modules/singoliMandrini/ricerca/viewRicerca.jsp" method="post">
<fieldset>
<legend>Ricerca un mandrini</legend>
<div class="form-group" >
<label class="col-lg-2 control-label">Search by</label>
<div class="col-lg-6">
<div class="radio">
<label> <input onclick="showStuff('selection','status');" type="radio" name="searchType" value="id_singoli" />id mandrino</label>
</div>
<div class="radio">
<label> <input onclick="showStuff('selection','status');" type="radio" name="searchType" value="id_tipo" />id tipo</label>
</div>
<div class="radio">
<label> <input onclick="showStuff('selection','status');" type="radio" name="searchType" value="model" />model</label>
</div>
<div class="radio">
<label> <input onclick="showStuff('status','selection');" type="radio" name="searchType" value="status" />stato</label>
</div>
<div class="radio">
<label> <input onclick="showStuff('selection','status');" type="radio" name="searchType" value="linea" />linea</label>
</div>
</div>
</div>
<div class="form-group tempHide" id="selection">
<label for="inputEmail" class="col-lg-2 control-label">Search keywords</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="searchKey" placeholder="keywords" />
</div>
</div>
<div class="form-group tempHide" id="status">
<label for="select" class="col-lg-2 control-label">Search keywords</label>
<div class="col-lg-4">
<select class="form-control input-sm" name="searchKey">
<option value="disponibile">disponibile</option>
<option value="montato">montato</option>
<option value="scrap">scrap</option>
</select>
</div>
</div>
</fieldset>
<p class="text-right">
<input class="btn btn-info" type="submit" value="Ricerca" name="ricerca" />
</p>
</form>
</div>
<% if(request.getParameter("ricerca")!=null) {
ricercaTipo ric = new ricercaTipo();
ArrayList<ricercaBean> list = new ArrayList<ricercaBean>();
list = ric.search(ricerca);
if(list.size()>0){
%>
<div class="well">
<table class="table table-striped table-hover ">
<thead>
<tr>
<th>#</th>
<th>id</th>
<th>Brand</th>
<th>Model</th>
<th>RPM</th>
<th>Nota</th>
</tr>
</thead>
<tbody>
<% for(int index=0;index<list.size();index++) { %>
<tr class="active">
<td><%=index+1%></td>
<td><%=list.get(index).getId_mandrino()%></td>
<td><%=list.get(index).getId_tipo()%></td>
<td><%=list.get(index).getModel()%></td>
<td><%=list.get(index).getTimeStamp()%></td>
<td><%=list.get(index).getStatus()%></td>
</tr>
<%} %>
</tbody>
</table>
</div>
<% }else{%>
<div class="alert alert-dismissable alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Oh No!</strong> No data found for the term "<%=ricerca.getSearchType()%>" <%=ricerca.getSearchKey()%>. Try again.
I am using Jsp Beans to send the data.

Your select dropdown and text input both have the same name so their value are mapped to the same variable on the bean. You should give them different names

Related

how to pass the value of an object to another object, already as a variable in Angular?

My class Inbound looks like down bellow.
export class Inbound {
constructor(
public id: number,
public incomingType: string,
public quantity: number,
public location: string,
public arrived: Date,
public bin: Bin,
public truck: Truck,
public supplier: Supplier
) {
HTML ->
<tr>
<th>ID</th>
<th>Incoming Type</th>
<th>Quantity</th>
<th>Location</th>
<th>Arrived</th>
<th>Bin</th>
<th>Truck</th>
<th>Supplier</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let inbound of inbounds">
<td><span>{{inbound.id}}</span></td>
<td><span>{{inbound.incomingType}}</span></td>
<td><span>{{inbound.quantity}}</span></td>
<td><span>{{inbound.location}}</span></td>
<td><span>{{inbound.arrived}}</span></td>
<td><span>{{inbound.bin.name}}</span></td>
<td><span>{{inbound.truck.regNumber}}</span></td>
<td><span>{{inbound.supplier.name}}</span></td>
<td>
I have problems with passing these 3 last variables because.
My code in Java works, i have checked on Postman.
Frontend in Angular meets some lack of knowledge by my side.
Method createNewInbound is not visible fron Angular.
<ng-template #content let-modal>
<div class="modal-header">
<h4 class="modal-title" id="modal-basic-title">New Inbound</h4>
<button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form #f="ngForm" (ngSubmit)="onSubmit(f)" novalidate>
<div class="form-group">
<label for="incomingType">Incoming Type</label>
<div class="input-group">
<input id="incomingType" name="incomingType" class="form-control" ngModel>
</div>
</div>
<div class="form-group">
<label for="quantity">Quantity</label>
<div class="input-group">
<input id="quantity" name="quantity" class="form-control" ngModel>
</div>
</div>
<div class="form-group">
<label for="location">Location</label>
<div class="input-group">
<input id="location" name="location" class="form-control" ngModel>
</div>
</div>
<div class="form-group">
<label for="arrived">Arrived</label>
<div class="input-group">
<input id="arrived" name="arrived" class="form-control" ngModel>
</div>
***[FROM HERE !!!]
**</div>
<div class="form-group">
<label for="bin.name">Bin Name</label>
<div class="input-group">
<input id="bin.name" name="bin.name" class="form-control" ngModel>
</div>
</div>
<div class="form-group">
<label for="truck.regNumber">Truck Reg Number</label>
<div class="input-group">
<input id="truck.regNumber" name="truck.regNumber" class="form-control" ngModel>
</div>
</div>
<div class="form-group">
<label for="supplier.name">Supplier Name</label>
<div class="input-group">
<input id="supplier.name" name="supplier.name" class="form-control" ngModel>
</div>
[TILL HERE!!!]*****
</div>
<div class="border text-center">
<button data-dismiss="modal" class="btn btn-info">Submit</button>
</div>
</form>
</div>
I realize that it might looks like Butter butter and might be time-consuming.
If somobody is willing to help me it might be great New Year surpise for me.
Here is my repo -> https://github.com/sroko1/Shipping-Bins.git.
Have a good day & year.
I
You would need to make use of ngModelGroup directive. Below is the code snippet:
<div class="form-group" ngModelGroup="bin"> <!-- Added ngModelGroup="bin" -->
<label for="bin">Bin Name</label>
<div class="input-group">
<input id="bin" name="name" class="form-control" ngModel> <!-- Updated name attribute value -->
</div>
</div>
<div class="form-group" ngModelGroup="truck"> <!-- Added ngModelGroup="truck" -->
<label for="truck.regNumber">Truck Reg Number</label>
<div class="input-group">
<input id="truck.regNumber" name="regNumber" class="form-control" ngModel> <!-- Updated name attribute value -->
</div>
</div>
<div class="form-group" ngModelGroup="supplier"> <!-- Added ngModelGroup="supplier" -->
<label for="supplier.name">Supplier Name</label>
<div class="input-group">
<input id="supplier.name" name="name" class="form-control" ngModel> <!-- Updated name attribute value -->
</div>
</div>
This will help you to get expected f.value within onSubmit()

Alignment of label and textbox

I am facing this issue again with the alignment which I am unable to rectify. I don't know what I am missing out. Please find the plunkr [https://plnkr.co/edit/UD0YZQhgOjIoJ1nqg7sb?p=preview] .Please maximise the plunkr output for the actual output I am getting. Any help people?
Html code:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div ng-controller="headerCtrl">
<div class="container" style="padding-top:20px;">
<div ng-app="TimeSheet" data-ng-controller="headerCtrl" class="container" style="margin-top:60px">
<div ng-show="error" class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span>
</button>
<p>{{ error }}</p>
</div>
<!--<p><a data-ng-click="showadd()" href="javascript:;" class="btn btn-primary">Generate Report</a></p>-->
<div class="panel panel-default">
<div class="panel-body">
<section>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="form-horizontal">
<div class="form-group">
<label for="title" class="col-sm-5 control-label">UserID</label>
<div class="col-sm-4">
<select data-ng-model="user.userid" class="form-control" id="title" required>
<option value="" selected="selected">(Select User ID)</option>
<option value="user1">user1</option>
<option value="user2">user2</option>
<option value="user3">user3</option>
<option value="user4">user4</option>
</select>
<!--<input type="text" data-ng-model="user.userid" class="form-control" id="title" placeholder="Enter your User ID" required title="Enter your UserID" />-->
</div>
</div>
<div class="form-group">
<label for="title" class="col-sm-5 control-label">Status</label>
<div class="col-sm-4">
Active
<input name="Status" type="radio" data-ng-model="user.ResultStatus" value="Active" required title="Choose status"> In-Active
<input name="Status" type="radio" data-ng-model="user.ResultStatus" value="InActive" required title="Choose status">
</div>
</div>
<div class="form-group">
<label for="startDate" class="col-sm-5 control-label">Date</label>
<div class="col-sm-4">
<input name="startDate" data-ng-model="user.date" id="startDate" class="date-picker" required />
<!--<input type="text" data-ng-model="user.projectid" class="form-control" id="title" placeholder="Enter your Project ID" required title="Enter your ProjectID" />-->
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-4">
<span data-ng-hide="editMode">
<input type="submit" value="Generate" ng-disabled="adduserform.$invalid" data-ng-click="add()" class="btn btn-primary" />
</span>
<span data-ng-show="editMode">
<input type="submit" value="Update" ng-disabled="adduserform.$invalid" data-ng-click="update()" class="btn btn-primary" />
</span>
<input type="button" value="Cancel" data-ng-click="cancel()" class="btn btn-primary" />
</div>
</div>
</div>
</div>
</div>
</section>
</div>
</div>
</div>
you can see the alignment issue here in this image below
To make the date input span the whole width, you need the .form-control class on it.
<input name="startDate" data-ng-model="user.date" id="startDate" class="form-control date-picker" required />
Also note that the <input> tag must have a type attribute with it.
You have a container within a container for your timesheet div. Removing the .container class from the timesheet div fixes the alignment issue.
Also, put the <table> in a row and a column:
<div class="row">
<div class="col-md-12">
<!-- Your table here -->
<table class="table table-hover">
...
</table>
</div>
</div>
See it working here.

Laravel Model Not Saving

Model is saving but all is null values excepts dates
There is not thrown error.
$fillable are directly copied from the field at my migrations.
I cant find why is that it is saving null values on the database
Here is my Code
My Model
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Disbursement_Information extends Model
{
use SoftDeletes;
protected $table = 'disbursement';
protected $fillable = [
'cv_number',
'payee_id',
'amount',
'check_number',
'release_date',
'first_collection_date',
'last_collection_date',
'maturity_date'
];
protected $dates = [
'created_at',
'updated_at',
'deleted_at'
];
}
My Controller
public function postDisbursement(Request $request, $id){
$loans = new Disbursement_Information;
$input = $request->all();
$loans->save($input);
}
HTML FORM
<div id="step-1">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header"> List of All Clients</h1>
<h2>Total Clients: <b>3</b></h2>
<div class="row">
</div>
</div>
</div>
<!-- /.col-lg-12 -->
</div>
<hr>
<div class="col-lg-6 col-md-6">
<div class="form-group">
<label for="cv_number"> Check Voucher # </label>
<input type="text" class="form-control" name="cv_number" id="cv_number" required>
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="form-group">
<label for="check_number"> Check # </label>
<input type="text" class="form-control" name="check_number" id="check_number" required>
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="form-group">
<label for="first_collection_date"> First Payment </label>
<input type="date" class="form-control" name="first_collection_date" id="first_collection_date" required>
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="form-group">
<label for="last_collection_date"> Last Payment </label>
<input type="date" class="form-control" name="last_collection_date" id="last_collection_date" required>
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="form-group">
<label for="maturity_date"> Maturity Date </label>
<input type="date" class="form-control" name="maturity_date" id="maturity_date" required>
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="form-group">
<label for="payee_name"> Payee </label>
<input type="text" class="form-control" name="payee_name" id="payee_name" readonly>
<input type="hidden" class="form-control" name="payee_id" id="payee_id" required>
</div>
</div>
<input type="hidden" name="_token" value="JvvXJbloRAzQnj4oz4ve6Z8OLLia270Fs6utSO5a">
<table class="table table-striped">
<thead>
<th>Name</th>
<th style="">Loan Amount</th>
<th style="text-align:center">Action</th>
</thead>
<tbody>
<tr >
<td class="">
Morgado, Ashbee, Allego
</td>
<td>
<input type="number" min="2000" max="99000" name="loan_amount[1]" class="form-control loan-amount">
</td>
<td style="text-align:center">
<div class="radio">
<label><input type="checkbox" class="reloan" name="reloan[1]" p_id = "1 "p_name="Morgado, Ashbee, Allego" target-rdb="rdb1"> Not re-loaning/loaning </label>
<label id="rdb1"><input type="radio" class="rdbPayee" name="payee_id" value="1" p_name="Morgado, Ashbee, Allego">Mark As Payee</label>
<button type="button" class="btn btn-sm btn-default loan-summary"><i class="fa fa-info-circle fa-5" aria-hidden="true"></i></button>
</div>
</td>
</tr>
<tr >
<td class="">
Melton, Barbara, None
</td>
<td>
<input type="number" min="2000" max="99000" name="loan_amount[2]" class="form-control loan-amount">
</td>
<td style="text-align:center">
<div class="radio">
<label><input type="checkbox" class="reloan" name="reloan[2]" p_id = "2 "p_name="Melton, Barbara, None" target-rdb="rdb2"> Not re-loaning/loaning </label>
<label id="rdb2"><input type="radio" class="rdbPayee" name="payee_id" value="2" p_name="Melton, Barbara, None">Mark As Payee</label>
<button type="button" class="btn btn-sm btn-default loan-summary"><i class="fa fa-info-circle fa-5" aria-hidden="true"></i></button>
</div>
</td>
</tr>
<tr >
<td class="">
Bonyton, Ester, Jaxis
</td>
<td>
<input type="number" min="2000" max="99000" name="loan_amount[3]" class="form-control loan-amount">
</td>
<td style="text-align:center">
<div class="radio">
<label><input type="checkbox" class="reloan" name="reloan[3]" p_id = "3 "p_name="Bonyton, Ester, Jaxis" target-rdb="rdb3"> Not re-loaning/loaning </label>
<label id="rdb3"><input type="radio" class="rdbPayee" name="payee_id" value="3" p_name="Bonyton, Ester, Jaxis">Mark As Payee</label>
<button type="button" class="btn btn-sm btn-default loan-summary"><i class="fa fa-info-circle fa-5" aria-hidden="true"></i></button>
</div>
</td>
</tr>
</tbody>
</table>
<div class="modal-footer">
<button type="submit" class="btn btn-success"> Submit </button>
</div>
</div>

Table column are not getting divided from center

This is how my page looks like.
This is code for same.
<table class="table table-bordered">
<tbody>
<tr>
<td>
<h4>Name & address</h4>
<div class="Name">
<input ng-model="Name" type="text" placeholder="Name" class="form-control"/>
</div>
<div class="Name">
<textarea class="form-control" ng-model="Address" placeholder="Address.." rows="4"></textarea>
</div>
<div class="Name">
<select ng-init="City=Chhatarpur" ng-model="City" class="form-control">
<option value="" ng-selected="selected">City</option>
<option value="Chhatarpur" ng-selected="selected">Chhatarpur</option>
</select>
</div>
<div class="Name">
<!--<input type="text" value="+91" class="form-control" size="2" disabled/>-->
<input ng-model="Mobile" type="text" placeholder="Mobile Number" class="form-control" maxlength="10"/>
</div>
</td>
<td>
<h4>Date/time of delivery</h4>
<div ng-if="(CurrentHour>=18 && CurrentHour<24) || (CurrentHour>=1 && CurrentHour<9)" >
<input type="radio" ng-model="order.delivery" value="5"> Tomorrow (09:00-12:00) <br/>
<input type="radio" ng-model="order.delivery" value="6"> Tomorrow (12:00-15:00) <br/>
<input type="radio" ng-model="order.delivery" value="7"> Tomorrow (15:00-18:00) <br/>
<input type="radio" ng-model="order.delivery" value="8"> Tomorrow (18:00-21:00)
</div>
<h4>Payment option </h4>
<input type="radio" ng-model="order.payment" value="Cash on delivery"> Cash on delivery <br/>
<input type="radio" ng-model="order.payment" value="Card on delivery"> Card on delivery
<button style="margin-top:20px;" type="button" class="btn btn-lg btn-primary btn-block" ng-click="">Place order</button>
</td>
</tr>
</tbody>
</table>
It looks like left column taking more width than right one. I want both columns should use 50% of screen width.
What is wrong here. Can some-one please help.
Give each td a width of 50%.
<table class="table table-bordered">
<tbody>
<tr>
<td width="50%">
<h4>Name & address</h4>
<div class="Name">
<input ng-model="Name" type="text" placeholder="Name" class="form-control"/>
</div>
<div class="Name">
<textarea class="form-control" ng-model="Address" placeholder="Address.." rows="4"></textarea>
</div>
<div class="Name">
<select ng-init="City=Chhatarpur" ng-model="City" class="form-control">
<option value="" ng-selected="selected">City</option>
<option value="Chhatarpur" ng-selected="selected">Chhatarpur</option>
</select>
</div>
<div class="Name">
<!--<input type="text" value="+91" class="form-control" size="2" disabled/>-->
<input ng-model="Mobile" type="text" placeholder="Mobile Number" class="form-control" maxlength="10"/>
</div>
</td>
<td width="50%">
<h4>Date/time of delivery</h4>
<div ng-if="(CurrentHour>=18 && CurrentHour<24) || (CurrentHour>=1 && CurrentHour<9)" >
<input type="radio" ng-model="order.delivery" value="5"> Tomorrow (09:00-12:00) <br/>
<input type="radio" ng-model="order.delivery" value="6"> Tomorrow (12:00-15:00) <br/>
<input type="radio" ng-model="order.delivery" value="7"> Tomorrow (15:00-18:00) <br/>
<input type="radio" ng-model="order.delivery" value="8"> Tomorrow (18:00-21:00)
</div>
<h4>Payment option </h4>
<input type="radio" ng-model="order.payment" value="Cash on delivery"> Cash on delivery <br/>
<input type="radio" ng-model="order.payment" value="Card on delivery"> Card on delivery
<button style="margin-top:20px;" type="button" class="btn btn-lg btn-primary btn-block" ng-click="">Place order</button>
</td>
</tr>
</tbody>
</table>
JSFiddle Here
use column width classes since you are using the class table table-bordered I guess you are using bootstrap css.
if you are using bootstrapv3.0 and above use below
<div class="col-md-6">
// LEFT COLUMN CODE GOES HERE
</div>
<div class="col-md-6">
// RIGHT COLUMN CODE GOES HERE
</div>
if you are using less than bootstrapv3.0
<div class="span6">
// LEFT COLUMN CODE GOES HERE
</div>
<div class="span6">
// RIGHT COLUMN CODE GOES HERE
</div>

form submitting not refresing value if get out the button

I have a form, that I need my save button to be outside of form elements, but if I take it out elsewhere, it doesn`t like refresh the form.
<form ng-submit="save()" action="" name="addInv" novalidate>
<div class="col-md-10">
<label>Name:</label>
<input type="text" ng-model="newlocation.name" class="form-control">
</div>
<div class="col-md-10">
<label>Storage administrator:</label>
<select ng-model="newlocation.administrator" class="form-control" ng-options="user.resource_uri as user.first_name for user in users"></select>
</div>
<div class="col-md-6">
<label>Street:</label>
<input type="text" ng-model="newlocation.street" class="input-medium form-control">
</div>
<div class="col-md-6">
<label>City:</label>
<input type="text" ng-model="newlocation.city" class="input-medium form-control">
</div>
<div class="col-md-6">
<label>Country:</label>
<input type="text" ng-model="newlocation.country" class="input-medium form-control">
</div>
<div class="col-md-6">
<label>Postal code:</label>
<input type="text" ng-model="newlocation.postalCode" class="input-medium form-control">
</div>
<div class="col-md-6">
<button class="btn tbn-lg btn-primary">Save</button>
</div>
</form>
If I put button outside the <form> form doesn't refresh values.
You could use JavaScript to do this
<input type="submit" onclick="document.forms[0].submit();" />