By using this component, retrieve parent class data - javascript

While from the onChange event, I had called a new functions by using this (i.e.) validateCommuteDate($(this)). I can get a value for that class. But how do I get another class value?
My HTML data is:
<div class="inner-row" id="pension-transaction-row-3" data-pension-row-id="3" style="margin-top: -6px; margin-bottom: -6px;">
<div class="col-sm-1" style="width:3%;padding-top:32px; "><span id="pensionName_3"></span></div>
<div class="col-sm-3 showError for-transaction-type-3">
<label class="mobile-label visible-xs">Transaction</label>
<label class="mobile-label hidden-xs"> </label>
<select name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][transaction_type_id]" class="form-control pensionTransactionType" id="pension_transaction_type_3" style="padding:6px 6px;">
<option value="">-- Select --</option>
<option value="commence">Pension Commencement</option>
</select>
</div>
<div class="col-sm-8 has-deleticon">
<div class="col-sm-3 showError for-pension-transaction-date-3">
<label class="mobile-label visible-xs">Date</label>
<label class="mobile-label hidden-xs"> </label>
<input name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][transaction_date]" class="form-control date-wheel-select transaction-date-wheel tdate" id="pension_transaction_date_3" placeholder="Date (DD/MM/YYYY)" style="padding:6px 6px;" value="01/06/2015" type="text"></div>
<div class="col-sm-5">
<label class="mobile-label visible-xs">Amount</label>
<div class="showError for-pension-transaction-amount-type-3 col-sm-12" style="display: block;">
<label class="mobile-label hidden-xs"> </label>
<div class="">
<select name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][pension_amount_type]" id="pension_amount_type_3" class="form-control pensionAmountType" style="padding: 6px 5px;">
<option value="">-- Select --</option>
<option value="1" selected="selected">Entire Balance</option>
<option value="2">Specific Amount</option>
</select>
</div>
</div>
<div class="col-sm-6 showError for-pension-transaction-amount-3" style="display: none;">
<label class="mobile-label hidden-xs"> </label>
<div class="input-group input-group-small">
<span class="input-group-addon">$</span>
<input name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][transaction_amount]" class="form-control pensionTransactionAmount text-right" style="padding:6px 6px;" value="0" type="text" id="ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension3TransactionAmount" placeholder="Amount"> </div>
</div>
</div>
<div class="col-sm-4" id="columnLabels-3">
<div class="col-sm-6 columnMemberOne showError for-pension-transaction-member-1-3" style="padding-right:1px;">
<label class="mobile-label columnLabelOne" style="display: none;">Deceased Member</label>
<label class="mobile-label columnLabelhidden Onehidden-xs"> </label>
<select name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][member_1]" class="form-control memberOne form-control-sm member12" id="member_1_3">
<option value="">-- Select --</option>
<option value="1" selected="selected">Adam</option>
<option value="2">Betty</option>
</select>
</div>
<div class="col-sm-6 columnMemberTwo showError for-pension-transaction-member-2-3" style="padding-left: 6px; display: none;">
<label class="mobile-label columnLabelTwo" style="display: none;">Receiving Member</label>
<select name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][member_2]" class="form-control memberTwo form-control-sm" id="member_2_3">
<option value="">-- Select --</option>
<option value="1">Adam</option>
<option value="2">Betty</option>
</select>
</div>
<div class="col-sm-6 showError for-pensionCommutationNumber-3">
<label class="mobile-label columnLabelOne" style="display: none;">Deceased Member</label>
<label class="mobile-label columnLabelhidden Onehidden-xs"> </label>
<select name="data[ClientLimeSmsfActuarialFormsMembersOneOffTransactionPension][3][pension_commutation_number]" class="form-control pensionCommutationNumber" id="pensionCommutationNumber_3"><option value="0" selected="selected">--Select--</option><option value="1A">1A</option><option value="1B">1B</option></select> </div>
</div>
<button class="btn-delete pensionCloneRemove" data-pension-div-id="3" style="top: 24px;"><i class="fa fa-trash-o"></i></button>
</div>
</div>
In OnChange event:
$(document).on('change', '.tdate', function(){
validateCommuteDate($(this));
});
ValidateCommuteDate function:
function validateCommuteDate($this){
var a = $this.val();
}
How can I retrieve pensionCommutationNumber value and pensionTransactionType value?

function validateCommuteDate($this){
var row_id = $this.parents('.inner-row').attr('data-pension-row-id'); // Get the row id
var transactionType = $('#pension_transaction_type_'+row_id).val(); // Retrieve the transaction type value
var name = $('#pensionCommutationNumber_'+row_id).val(); // Retrieve the Pension Commutation Value
}

Related

How can I convert form data with multiple sections to json

I am trying to save data in html form as json. But only my last row is saved. The reason for this is probably because the names of the inputs in the two sections are the same.
But I want the json file like this:
{"name":"Name1","surname":"Surname1","gender":"f","birthDay":"15","birthMonth":"1","birthYear":"1995"},
{"name":"Name2","surname":"Surname2","gender":"m","birthDay":"20","birthMonth":"2","birthYear":"2020"}
But now output is:
{"name":"Name2","surname":"Surname2","gender":"m","birthDay":"20","birthMonth":"2","birthYear":"2020"}
function handleFormSubmit(event) {
event.preventDefault();
const data = new FormData(event.target);
const formJSON = Object.fromEntries(data.entries());
console.log(JSON.stringify(formJSON))
}
const form = document.querySelector('#example-form');
form.addEventListener('submit', handleFormSubmit);
<div class="container py-4">
<form id="example-form">
<div class="row">
<div class="col-md-12 p-0">
<div class="col-md-12 form_field_outer p-0" id="app">
<div class="row form_field_outer_row">
<div class="form-group col-md-2">
<input class="form-control w_90" id="name" name="name" placeholder="Name" type="text" value="" /></div>
<div class="form-group col-md-2">
<input class="form-control w_90" id="surname" name="surname" placeholder="Surname" type="text" value="" /></div>
<div class="form-group col-md-2">
<select class="form-control" id="gender" name="gender"><option disabled="disabled" selected="selected">Gender</option>
<option value="f">Female</option>
<option value="m">Male</option>
<option value="n">None.</option></select></div>
<div class="form-group col">
<input class="form-control w_90" id="birthDay" maxlength="2" name="birthDay" placeholder="Day" type="text" value="" /></div>
<div class="form-group col">
<select class="form-control" id="birthMonth" name="birthMonth">
<option disabled="disabled" selected="selected">Month</option>
<option value="1">Jan</option>
<option value="2">Feb</option>
<option value="3">Mar</option>
</select>
</div>
<div class="form-group col">
<input class="form-control w_90" id="birthYear" maxlength="4" name="birthYear" placeholder="Year" type="text" value="" /></div>
</div>
<br>
<div class="row form_field_outer_row">
<div class="form-group col-md-2">
<input class="form-control w_90" id="name" name="name" placeholder="Name" type="text" value="" /></div>
<div class="form-group col-md-2">
<input class="form-control w_90" id="surname" name="surname" placeholder="Surname" type="text" value="" /></div>
<div class="form-group col-md-2">
<select class="form-control" id="gender" name="gender"><option disabled="disabled" selected="selected">Gender</option>
<option value="f">Female</option>
<option value="m">Male</option>
<option value="n">None.</option></select></div>
<div class="form-group col">
<input class="form-control w_90" id="birthDay" maxlength="2" name="birthDay" placeholder="Day" type="text" value="" /></div>
<div class="form-group col">
<select class="form-control" id="birthMonth" name="birthMonth">
<option disabled="disabled" selected="selected">Month</option>
<option value="1">Jan</option>
<option value="2">Feb</option>
<option value="3">Mar</option>
</select>
</div>
<div class="form-group col">
<input class="form-control w_90" id="birthYear" maxlength="4" name="birthYear" placeholder="Year" type="text" value="" /></div>
</div>
</div>
</div>
</div>
<br>
<div class="col-md ml-0 mt-3 py-3">
<div class="col-md-12">
<button type="submit" id="submitId" class="btn btn-success float-right "><i class="fa fa-check-circle"></i> Submit</button>
</div>
</div>
</form>
</div>
How can I solve this?
Thanks for answers.
You have to have unique id and name values to your form elements.
So change the two occurences of:
<input id="surname" name="surname">
to something like this:
<input id="surname_0" name="person[0][surname]">
And the second occurence:
<input id="surname_1" name="person[1][surname]">
(I removed all other attributes to improve readability for my answer)

How can I do it : When checked radio button change input required?

I need help. I have 3 radio button 1. Credit Cart 2. Cargo Payment
3. Bank Payment
So I want when checked id ="credit" (Credit Cart) : Credit cart information inputs to be required with JS.
When the selected Radio button becomes credit card, the card information is opened. No card payment is required when others are selected. Therefore, it will be mandatory to enter information only when cart is selected.
$('input[name="cname"]').change(function() {
if ($("#kart").is(':checked')) {
$('#cname').add.attr('required');
$('#cnumber').add.attr('required');
$('#cmonth').add.attr('required');
$('#cyear').add.attr('required');
$('#ccvc').add.attr('required');
} else {
$('#cname').removeAttr('required');
$('#cnumber').removeAttr('required');
$('#cmonth').removeAttr('required');
$('#cyear').removeAttr('required');
$('#ccvc').removeAttr('required');
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="d-block my-3">
<div class="custom-control custom-radio" id="kart">
<input id="credit" name="paymentType" checked type="radio" value="Kredi Kartı" class="custom-control-input">
<label class="custom-control-label" for="credit">Paiement par carte Kreadi</label>
</div>
<div class="custom-control custom-radio" id="kapida">
<input id="cargo" name="paymentType" type="radio" value="Kapıda Ödeme" class="custom-control-input">
<label class="custom-control-label" for="cargo">Payer à la Porte</label>
</div>
<div class="custom-control custom-radio" id="havale">
<input id="bank" name="paymentType" type="radio" value="Banka Havale" class="custom-control-input">
<label class="custom-control-label" for="bank">Paiement par Virement Bancaire</label>
</div>
</div>
<div class="row" id="kartodeme">
<div class="col-sm-6">
<div class="row">
<div class="col-md-12 mb-3">
<label for="">Nom et Prénom Sur la Carte</label>
<input type="text" name="cname" class="form-control" id="cname" placeholder="Prénom / Nom de Famille">
</div>
</div>
<div class="row">
<div class="col-md-12 mb-3">
<label for="">Numéro de Carte</label>
<input type="text" name="cnumber" min="16" max="16" class="form-control" id="cnumber" placeholder="XXXX-XXXX-XXXX-XXXX">
</div>
</div>
<div class="row">
<div class="col-md-12 mb-1">
<label for="">Date d'expiration</label>
</div>
<div class="col-md-4 mb-3">
<label for="">Lune</label>
<select name="cmonth" id="cmonth" class="form-control">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</div>
<div class="col-md-4 mb-3">
<label for="">An</label>
<select name="cyear" id="cyear" class="form-control">
<option value="20">2020</option>
<option value="21">2021</option>
<option value="22">2022</option>
<option value="23">2023</option>
<option value="24">2024</option>
<option value="25">2025</option>
<option value="26">2026</option>
<option value="27">2027</option>
<option value="28">2028</option>
<option value="29">2029</option>
</select>
</div>
<div class="col-md-4 mb-3">
<label for="">CVC</label>
<input type="text" name="ccvc" class="form-control" id="ccvc" placeholder="123">
</div>
</div>
</div>
<div class="col-sm-6">
</div>
</div>
Your question isn't so clear, but if you are trying to enforce validation when #credit radio is checked you can approach it as follows:
Store a variable, let's call it const isValidationRequired = false;
Have event listeners on all radio inputs. Let's say you add a class radios-wrapper on the parent div, so select the following:
`
function handleRadioClick(e) {
const targetId = e.target.id;
if (targetId == "credit") {
isValidationRequired = true;
}
}
const radiosWrapper = document.querySelector('.radios-wrapper');
const radios = radiosWrapper.querySelectorAll('input[type='radio']');
radios.forEach(radio => radio.addEventListener('click', handleRadioClick))
Several things
You want to run on click of the radio
You want to test credit and not kart
To validate a select, it needs an empty <option value="">Month</option>
const cc = () => {
const checked = $("#credit").is(':checked');
['cnumber', 'cmonth', 'cyear', 'ccvc', 'cname'].forEach(ele => {
$ele = $("#" + ele);
if ($ele.length > 0) { // test if the element exists
if (checked) $ele.attr("required", true);
else $ele.removeAttr("required");
}
})
};
$('[name=paymentType]').on('click', cc)
cc(); // on load
// extra code to generate the years from current year
const year = +String(new Date().getFullYear()).slice(2);
let curMonth = new Date().getMonth()+1;
$("#cyear")[0].options.length=1; // remove all but one
for (let i=year, n = year+9; i<=n;i++) {
$("#cyear").append($('<option/>',{text:i,value:i}));
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" />
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<div class="d-block my-3">
<div class="custom-control custom-radio" id="kart">
<input id="credit" name="paymentType" checked type="radio" value="Kredi Kartı" class="custom-control-input">
<label class="custom-control-label" for="credit">Paiement par carte Kreadi</label>
</div>
<div class="custom-control custom-radio" id="kapida">
<input id="cargo" name="paymentType" type="radio" value="Kapıda Ödeme" class="custom-control-input">
<label class="custom-control-label" for="cargo">Payer à la Porte</label>
</div>
<div class="custom-control custom-radio" id="havale">
<input id="bank" name="paymentType" type="radio" value="Banka Havale" class="custom-control-input">
<label class="custom-control-label" for="bank">Paiement par Virement Bancaire</label>
</div>
</div>
<div class="row" id="kartodeme">
<div class="col-sm-6">
<div class="row">
<div class="col-md-12 mb-3">
<label for="">Nom et Prénom Sur la Carte</label>
<input type="text" name="cname" class="form-control" id="cname" placeholder="Prénom / Nom de Famille">
</div>
</div>
<div class="row">
<div class="col-md-12 mb-3">
<label for="">Numéro de Carte</label>
<input type="text" name="cnumber" min="16" max="16" class="form-control" id="cnumber" placeholder="XXXX-XXXX-XXXX-XXXX">
</div>
</div>
<div class="row">
<div class="col-md-12 mb-1">
<label>Date d'expiration <input type="date" /></label>
</div>
<div class="col-md-4 mb-3">
<select name="cmonth" id="cmonth" class="form-control">
<option value="">Lune</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
</div>
<div class="col-md-4 mb-3">
<select name="cyear" id="cyear" class="form-control">
<option value="">An</option>
<option value="20">2020</option>
<option value="21">2021</option>
<option value="22">2022</option>
<option value="23">2023</option>
<option value="24">2024</option>
<option value="25">2025</option>
<option value="26">2026</option>
<option value="27">2027</option>
<option value="28">2028</option>
<option value="29">2029</option>
</select>
</div>
<div class="col-md-4 mb-3">
<label for="ccvc">CVC</label>
<input type="text" name="ccvc" class="form-control" id="ccvc" placeholder="123">
</div>
</div>
</div>
<div class="col-sm-6">
<input type="submit">
</div>
</div>

Set text field min and max value based on the option selected in previous dropdown

I have a drop down and a text box next to it.
When some value is selected in the dropdown, the textbox should allow min and max characters based on the selected option.
Suppose I select option 1, then the textbox next to it should allow minimum 10 characters and max 16 characters.
How to achieve it?
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="required">Select Type</label>
<select class="form-control" id="prooftype">
<option value="0" disabled> </option>
<option value="name1">name1</option>
<option value="name2">name2</option>
<option value="name3">name3</option>
<option value="name4">name4</option>
</select>
</div>
</div>
<div class="col-sm-6">
<div class="form-group md-form">
<label class="required" for="id" data-error="wrong" data-success="right">
<i class="fa fa-info pr-2"></i>
Enter Identity Card Number
</label>
<input id="id" type="number" minlength="3" class="form-control validate" autocomplete="off" onkeypress="return blockSpecialChar(event)" oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);" maxlength="20" />
</div>
</div>
</div>
you have to change a little your code
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="required">Select Type</label>
<select class="form-control" id="prooftype">
<option value="0/0" disabled> </option>
<option value="10/16">name1</option>
<option value="20/32">name2</option>
<option value="30/48">name3</option>
<option value="40/64">name4</option>
</select>
</div>
</div>
<div class="col-sm-6">
<div class="form-group md-form">
<label class="required" for="id" data-error="wrong" data-success="right">
<i class="fa fa-info pr-2"></i>
Enter Identity Card Number
</label>
<input id="id" type="text" minlength="3" class="form-control validate" autocomplete="off" onkeypress="return blockSpecialChar(event)" maxlength="20" />
</div>
</div>
</div>
and jQuery
$('#prooftype').change(function(){
var tmp = $(this).val().split('/');
$('input#id').attr('minlength',tmp[0]).attr('maxlength',tmp[1]);
})
If you pass the the option value of 12/16 to the backend, obviously the data will reflect. I think you need something like this:
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="required">Select Type</label>
<select class="form-control" id="prooftype">
<option value="0/0" disabled> </option>
<option value="name1">name1</option>
<option value="name2">name2</option>
<option value="name3">name3</option>
<option value="name4">name4</option>
</select>
</div>
</div>
<div class="col-sm-6">
<div class="form-group md-form">
<label class="required" for="id" data-error="wrong" data-success="right">
<i class="fa fa-info pr-2"></i>
Enter Identity Card Number
</label>
<input id="inputid" type="text" minlength="3" class="form-control validate" autocomplete="off" onkeypress="return blockSpecialChar(event)" maxlength="20" />
</div>
</div>
</div>
And your JQuery
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript">
var selectedopt;
$('#prooftype').change(function(){
selectedopt= $(this).val();
//Add your condition here, and check the selected option value:
if(selectedopt== "name1")
{
//Set input min and max value based on the selected option value.
$('#inputid').attr('minlength','10').attr('maxlength','16');
}
elseif(selectedopt== "name2")
{
$('#inputid').attr('minlength','20').attr('maxlength','25');
}
// And so on........
})
</script>

including javascript in a ".vm" file

This is my velocity(.vm) file. I need to write a code such that if I select an option from any 1 dropdown the other dropdwon gets disabled and if I choose the "--Select--" option, both dropdowns are enabled.
<div class="form-group">
<label for="pvncId" class="col-sm-2 control-label">Provincienaam</label>
<div class="col-sm-8">
<select id="pvncId" name="pvncId" title="Province" class="form-control
form_select">
<option value="">--Select--</option>
#foreach($pvnc in $provincelist)
<option value="$pvnc.gml_id">${pvnc.provincienaam}</option>
#end
</select>
<span class="help-block" id="help-block-service"></span>
</div>
<div class="col-sm-2"></div>
</div>
<div class="form-group">
<label for="gemId" class="col-sm-2 control-label">Gemeentenaam</label>
<div class="col-sm-8">
<select id="gemId" name="gemId" title="Gemeenten" class="form-control
form_select">
<option value="">--Select--</option>
#foreach($gem in $gemeentenlist)
<option value="$gem.gml_id">${gem.gemeentenaam}</option>
#end
</select>
<span class="help-block" id="help-block-service"></span>
</div>
<div class="col-sm-2"></div>
</div>

angular http.post input with ng-repeat and input with no ng-repeat

can anyone help me? In my code, I have a form which user have to input, but the value is not all of the data. So, I have put the ng-repeated value for the data that has been input before. And, I want to post it using angular but the ng-repeated data is return "undefined".
Is there any cure for this? Here is my code
<form class="sky-form" ng-submit="formDataDiri()" name="datadiriForm" novalidate>
<div class="row">
<div class="col col-12"><img src="images/icon_namapasien.png" alt=""/> Nama Pasien</div>
</div>
<div class="row">
<div class="col col-12">
<label class="input disabled" ng-repeat="data in dataDiri">
<input type="text" value="{{data.name}}" placeholder="{{data.name}}" name="name" ng-model="nama" disabled="">
</label>
</div>
</div><!-- /row -->
<div class="row">
<div class="col col-12"><img src="images/icon_tgl.png" alt=""/> Tanggal Lahir</div>
</div>
<div class="row">
<div class="col col-4">
<label class="input disabled" ng-repeat="data in dataDiri">
<input type="text" value="{{data.birth_day}}" placeholder="{{data.birth_day}}" name="name" ng-model="nama" disabled="">
</label>
</div>
<div class="col col-5">
<label class="input disabled" ng-repeat="data in dataDiri">
<input type="text" value="{{data.birth_month}}" placeholder="{{data.birth_month_name}}" name="name" ng-model="nama" disabled="">
</label>
</div>
<div class="col col-3">
<label class="input disabled" ng-repeat="data in dataDiri">
<input type="text" value="{{data.birth_year}}" placeholder="{{data.birth_year}}" name="name" ng-model="nama" disabled="" >
</label>
</div>
</div><!-- /row -->
<div class="row">
<div class="col col-12"><img src="images/icon_gender.png" alt=""/> Jenis Kelamin</div>
</div>
<div class="row">
<div class="col col-12">
<div class="select">
<label class="select">
<select name="JKelamin" ng-model="jeniskelamin" required="">
<option value="">Pilih Jenis Kelamin</option>
<option value="1">Pria</option>
<option value="0">Wanita</option>
</select>
<i></i>
</label>
</div>
</div>
</div><!-- /row -->
<div class="row">
<div class="col col-12"><img src="images/icon_alamat.png" alt=""/> Alamat</div>
</div>
<div class="row">
<div class="col col-12">
<label class="input disabled">
<input type="text" value="" ng-model="alamat" name="address" required=""/>
<input type="hidden" name="name" value="0" ng-model="kodekota">
</label>
</div>
</div><!-- /row -->
<div class="row">
<div class="col col-12"><img src="images/icon_telp.png" alt=""/> Nomor Telepon / Hp</div>
</div>
<div class="row">
<div class="col col-12">
<label class="input disabled">
<input type="text" value="" ng-model="notelp" name="hp" required="" minlength="6" maxlength="13"/>
</label>
</div>
</div><!-- /row -->
<div class="row">
<div class="col col-12"><img src="images/icon_layanan.png" alt=""/> Layanan</div>
</div>
<div class="tabform">
<ul class="tabs" ng-model="layanan">
<li class="tab-link" data-tab="tab-1" ng-click="homeservice()"> <span class="homeservice">Home Service</span></li>
<li class="tab-link current" data-tab="tab-2" ng-click="periksalab()"><span class="periksalab">Periksa di Lab</span></li>
</ul>
<div id="tab-1" class="tab-content">
<div class="row">
<div class="col col-12"><img src="images/icon_tgl.png" alt=""/> Tanggal Pemeriksaan</div>
</div>
<div class="row">
<div class="col-md-12">
<label class="input disabled">
<input type="text" ng-model="hs" class="datepicker1" />
</label>
</div>
<!-- <div class="col col-4">
<label class="select">
<select name="tanggalPeriksaHS" ng-model="dateperiksa" required="">
<option value="">Tanggal</option>
<option ng-repeat="n in range(1,31)" value="{{n}}">{{n}}</option>
</select>
<i></i>
</label>
</div>
<div class="col col-5">
<label class="select">
<select name="bulanPeriksaHS" ng-model="monthperiksa" required="">
<option value="">Bulan</option>
<option value="01">Januari</option>
<option value="02">Februari</option>
<option value="03">Maret</option>
<option value="04">April</option>
<option value="05">Mei</option>
<option value="06">Juni</option>
<option value="07">Juli</option>
<option value="08">Agustus</option>
<option value="09">September</option>
<option value="10">Oktober</option>
<option value="11">November</option>
<option value="12">Desember</option>
</select>
<i></i>
</label>
</div>
<div class="col col-3">
<label class="select">
<select name="tahunPeriksaHS" ng-model="yearperiksa" required="">
<option value="">Tahun</option>
<option value="2016" selected>2016</option>
</select>
<i></i>
</label>
</div> -->
</div><!-- /row -->
<div class="row">
<div class="col col-12"><img src="images/timeperkiraan.png" alt=""/> Perkiraan Jam Home Service</div>
</div>
<div class="row">
<div class="col col-12">
<label class="select disabled">
<select data-ng-options="h.id as h.time for h in dataHomeService.home_service_time" name="gender" ng-model="jamlayanan">
</select>
<i></i>
</label>
</div>
</div><!-- /row -->
<div class="row">
<div class="col col-12"><div class="smallprice">Tambahan biaya home service Rp <span>0.00</span></div></div>
</div>
</div>
<div id="tab-2" class="tab-content current">
<div class="row">
<div class="col col-12"><img src="images/icon_tgl.png" alt=""/> Tanggal Pemeriksaan</div>
</div>
<div class="row">
<label class="input disabled">
<input type="text" ng-model="periksa" class="datepicker2" />
</label>
<!-- <div class="col col-4">
<label class="select">
<select ng-model="dateperiksa" required="" name="tanggalPeriksaPL">
<option value="">Tanggal</option>
<option ng-repeat="n in range(1,31)" value="{{n}}">{{n}}</option>
</select>
<i></i>
</label>
</div>
<div class="col col-5">
<label class="select">
<select ng-model="monthperiksa" required="" name="bulanPeriksaPL">
<option value="">Bulan</option>
<option value="01">Januari</option>
<option value="02">Februari</option>
<option value="03">Maret</option>
<option value="04">April</option>
<option value="05">Mei</option>
<option value="06">Juni</option>
<option value="07">Juli</option>
<option value="08">Agustus</option>
<option value="09">September</option>
<option value="10">Oktober</option>
<option value="11">November</option>
<option value="12">Desember</option>
</select>
<i></i>
</label>
</div>
<div class="col col-3">
<label class="select">
<select ng-model="yearperiksa" required="" name="tahunPeriksaPL">
<option value="">Tahun</option>
<option value="2016" selected>2016</option>
</select>
<i></i>
</label>
</div> -->
</div><!-- /row -->
</div>
</div><!-- /tabform -->
<hr class="lineform" />
<button class="btn-yellow" type="submit" name="submit" ng-disabled="datadiriForm.$error.required">Lanjutkan Pemeriksaan</button>
<span ng-show="datadiriForm.$error.required"><center>Mohon mengisi dengan lengkap terlebih dahulu</center></span>
</form>
Here is my angular code for post:
$scope.formDataDiri = function(){
alert($scope.nama);
if($scope.layanan == '0'){
$http({
method: 'POST',
url: '/api/v1/order/datadiri',
data:{
nama_pasien: $scope.nama,
birth: $scope.year + "-" + $scope.month + "-" + $scope.date,
gender: $scope.jeniskelamin,
address: $scope.alamat,
city_code: "0",
phone: $scope.notelp,
service: $scope.layanan,
//test_date: $scope.yearperiksa + "-" + $scope.monthperiksa + "-" + $scope.dateperiksa,
test_date: $scope.hs,
service: $scope.layanan,
test_date_day: $scope.dateperiksa,
test_date_month: $scope.monthperiksa,
test_date_year: $scope.yearperiksa,
home_service_times: $scope.jamlayanan,
code: $scope.survey,
jawaban: $scope.lainnya
}
}).success(function(data,status){
$scope.dataPasien = data;
//alert($scope.nama);
$window.location.href = 'doctor/order/lab';
});
}else{
$http({
method: 'POST',
url: '/api/v1/order/datadiri',
data:{
nama_pasien: $scope.nama,
birth: $scope.year + "-" + $scope.month + "-" + $scope.date,
gender: $scope.jeniskelamin,
address: $scope.alamat,
city_code: "0",
phone: $scope.notelp,
service: $scope.layanan,
//test_date: $scope.yearperiksa + "-" + $scope.monthperiksa + "-" + $scope.dateperiksa,
test_date: $scope.periksa,
service: $scope.layanan,
test_date_day: $scope.dateperiksa,
test_date_month: $scope.monthperiksa,
test_date_year: $scope.yearperiksa,
home_service_times: $scope.jamlayanan,
code: $scope.survey,
jawaban: $scope.lainnya
}
}).success(function(data,status){
$scope.dataPasien = data;
//alert($scope.nama);
$window.location.href = 'doctor/order/lab';
});
}
Thank you for helping me.
I don't see any where in your controller, you are using $scope.data, replace your view in ng-repeat with dataPasien.
<label class="input disabled" ng-repeat="dataPasien in dataDiri">
<input type="text" value="{{dataPasien.name}}" placeholder="{{dataPasien.name}}" name="name" ng-model="nama" disabled="">
</label>

Categories