I have a html form, and i have also checkboxes in it. Values of checkboxes is coming from SQL-database via Web Api.
$(document).ready(function () {
var $MaterialName = $('#materiallist');
function addMaterials(material) {
$MaterialName.append('<input type="checkbox" >' + material.MaterialName + ' </input>');
}
<div class="form-group">
<label for="material" class="col-xs-3 control-label
header">Käytetyt materiaalit</label>
<div class="col-xs-7">
<div class="checkbox" id="materiallist"></div>
</div>
</div>
I want to save those checked values to another SQL-database (named Form), along with the other input values in that form.
I haven't found a solution where all the other input fields also needs to be saved as well, only solutions where is only checkboxes and button. And also that my values are coming from database, not "hard-code" options. I tried this:
function getCheckedMaterials() {
var materialArray = [];
$("#materiallist input:checked").each(function () {
materialArray.push($(this).val());
});
var selected;
selected = materialArray.join(',');
alert("You have selected " + selected);
}
But it doesn't work as i need, because i can't get values..
All these values from another input fields goes to Form-database when i press button #tallenna. I need checked values to be saved in MaterialName-column as text.
$('#tallenna').click(function () {
var form = {
FormFiller: $FormFiller.val(),
CustomerContact: $CustomerContact.val(),
ReadyToDate: $ReadyToDate.val(),
Instructions: $Instructions.val(),
Amount: $Amount.val(),
PcsAmount: $PcsAmount.val(),
ChargeFull: $ChargeFull.val(),
ChargeByPcs: $ChargeByPcs.val(),
FreightCost: $FreightCost.val(),
CustomerName: $CustomerName.val(),
WorkName: $WorkName.val(),
MaterialName: getCheckedMaterials // ????
};
Aucun commentaire:
Enregistrer un commentaire