我有动态表格,其各自的开始日期已添加,
在每个表格中都可以选择添加法律开始日期及其regno,
我希望法律开始日期的每个特定地点的开始日期
例如,如果我在某个位置开始日期添加05/09/2017,则此日期应显示为法律开始日期的05/09/2017。
上面是一个表单的截图,我有多个表单作为这些
任何人都可以帮助我。?
我的代码是这样的:
$(document).on('click','.date-picker2',function(e){
var startdate = $(this).parent().parent().parent().parent().parent().attr('data-loc');
startdate = $("#start_" + startdate).val();
var splits = startdate.split("-");
alert(splits);
$(this).datepicker({
todayBtn: "linked",
autoclose: true,
format: 'dd-mm-yyyy',
startDate: new Date(splits[2]+"-"+splits[1]+"-"+splits[0]),
endDate: new Date(),
onSelect:function(date){
}
}).datepicker("show");
});
它的问题是它只给我第一个位置的开始日期
不是第二次和第三次等。
我想要特定地点的开始日期。
我的表格是:
{!! Form::open(array('url' => 'admin/companymaster/updatelocationsdata', 'id'=>'location_update','method'=>'Post', 'class' => 'form-horizontal', 'files' => true)) !!}
<div class="modal-content">
<input type="hidden" name="company_id" id="company_id" value="{{$value->company_id}}">
<input type="hidden" name="location_id" id="location_id" value="{{$value->id}}">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title">View Location</h4>
</div>
<div class="modal-body">
<div class="row">
<div id="locationid_1">
<div class="row" style="padding-bottom:5px;">
<div class="col-md-4">
<div class="form-group">
<label class="control-label col-md-4">CMS ID:<span class="required" aria-required="true">* </span></label>
<div class="col-md-7">
<input type="text" name="cms_id" id="cms_id" class="form-control required " value="{{ $value->cms_id }}" aria-required="true" readonly="readonly">
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="control-label col-md-4">Country:<span class="required" aria-required="true">* </span></label>
<div class="col-md-7">
<input type="text" readonly="readonly" name="country_name" id="country_name" class="form-control required" aria-required="true" value="{{ $value->country_name }}">
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="control-label col-md-4">State:<span class="required" aria-required="true">* </span></label>
<div class="col-md-7">
<input type="text" readonly="readonly" name="state_name" class="form-control required " aria-required="true" value="{{ $value->state_name }}">
</div>
</div>
</div>
</div>
<div class="row" style="padding-bottom:5px;">
<div class="col-md-4">
<div class="form-group">
<label class="control-label col-md-4">Location:<span class="required" aria-required="true">* </span></label>
<div class="col-md-7">
<input type="text" name="location_name" id="location_name" class="form-control required location" aria-required="true" value="{{ $value->location_name }}" required>
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="control-label col-md-4">Start Date:<span class="required" aria-required="true">* </span></label>
<div class="col-md-7">
<input type="text" readonly="readonly" name="company_start_date" id="company_start_date" class="form-control required" placeholder="DD-MM-YYYY" aria-required="true" value="<?php if($value->company_start_date!=""){ echo date("d-m-Y", strtotime($value->company_start_date)); }?>">
</div> <!-- id="start_{{$value->id}}" -->
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="control-label col-md-4">End Date:</label>
<div class="col-md-7">
<?php
if($value->company_end_date!="")
{ $end_date = date("d-m-Y", strtotime($value->company_end_date)); }
if ($value->company_end_date =="0000-00-00")
{$end_date = null ;}
?>
<input type="text" name="end_date" id="end_date" class="company_end_date form-control date-picker required" onfocus="this.blur()" aria-required="true" disabled="disabled" value="{{$end_date}}" placeholder="DD-MM-YYYY" required>
</div>
</div>
</div>
</div>
<div class="row" style="padding-bottom:6px;">
<div class="col-md-4">
<div class="form-group">
<label class="control-label col-md-4">IT Admin:<span class="required" aria-required="true">* </span></label>
<div class="col-md-7">
<?php
$uservalue = DB::table('users')->where('company_id', $value->company_id)->where('role', 6)->where('location_id', $value->id)->whereNull('deleted_at')->first();
?>
<input type="text" readonly="readonly" name="company_admin" id="company_admin" class="form-control required" aria-required="true" value="{{ $uservalue->first_name }} {{ $uservalue->last_name }} ({{ $uservalue->email }})">
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="control-label col-md-4">Address:<span class="required" aria-required="true">* </span></label>
<div class="col-md-7">
<textarea name="company_location_address" class="form-control required" rows="3" aria-required="true" required>{{ $value->company_location_address }}</textarea>
</div>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label class="control-label col-md-4">Status:<span class="required" aria-required="true">* </span></label>
<div class="col-md-7">
<select name="company_status" id="company_status" class="form-control" onchange="setstatus(this.value);">
<option value="1" <?php if($value->company_status=='1'){ echo "selected=selected"; }?>>Active</option>
<option value="0" <?php if($value->company_status=='0'){ echo "selected=selected"; }?>>Inactive</option>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-10">
<div class="form-group">
<label class="control-label col-md-2">Add Laws<span class="required" aria-required="true">* </span></label>
<div class="col-md-10">
<a data-toggle="modal" id="" class="openmodal updateLaw" ><i class="fa fa-plus-square" style="font-size:24px;height:24px;" ></i></a>
<div class="updateloc">
<input type="hidden" value="{{$value->id}}" name="company_master_id">
<div class="sublaws_content" data-loc="{{$value->id}}"></div>
<div class="save" id="save" style="display:none; margin-bottom: 20px;">
<button type="button" class="btn btn-success location_law_update" disabled="disabled">Update</button>
<a class="btn red" href="{{ URL::to('admin/companymaster/'.$company_master->id) }}">Cancel</a>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" class="btn green right submitlocation" id="submitlocation">Update</button>
<button type="button" class="btn red" data-dismiss="modal">Close</button>
</div>
</div>
</form>
答案 0 :(得分:0)
在聚焦或更改事件时执行此操作。现在点击事件时点击事件,字段中没有值。
$( ".date-picker2" ).change(function() {
alert( "Do functions here" );
});