Hi there,
I hope someone can help me solve this problem. I have a form with 3 different fields being calculated by a custom javascript. The javascript is working as it should displaying the sum of the fields. The problem is that when the form is saved to the database the sum that is calculated is saved in the database as a 0. I need it to save the numbers that it is displaying to the users. I have tried many things trying to resolve this but I am afraid it is above my coding skillset and need any help I can get. I have included the JS and Form code below and attached screenshots of the database schema and the results that are saved:
I hope someone can help me solve this problem. I have a form with 3 different fields being calculated by a custom javascript. The javascript is working as it should displaying the sum of the fields. The problem is that when the form is saved to the database the sum that is calculated is saved in the database as a 0. I need it to save the numbers that it is displaying to the users. I have tried many things trying to resolve this but I am afraid it is above my coding skillset and need any help I can get. I have included the JS and Form code below and attached screenshots of the database schema and the results that are saved:
window.addEvent('domready', function () {
$('pinicial').addEvent('change', rekenen1);
$('pfinal').addEvent('change', rekenen1);
});
function rekenen1() {
$('tprinted').value = parseInt($('pfinal').value) - parseInt($('pinicial').value);
}
window.addEvent('domready', function () {
$('timpresas').readOnly = true;
$('rinicial').addEvent('change', rekenen2);
$('rfinal').addEvent('change', rekenen2);
});
function rekenen2() {
$('timpresas').value = parseInt($('rinicial').value) - parseInt($('rfinal').value);
}
window.addEvent('domready', function () {
$('subtotal').readOnly = true;
$('timpresas').addEvent('change', rekenen3);
$('vendidas').addEvent('change', rekenen3);
$('mermas').addEvent('change', rekenen3);
$('cortesias').addEvent('change', rekenen3);
});
function rekenen3() {
$('subtotal').value = parseInt($('vendidas').value) + parseInt($('mermas').value) + parseInt($('cortesias').value);
}
</fieldset>
<fieldset class="chronoform-container" id="chronoform-container-21">
<legend></legend>
<div class="form-group gcore-form-row" id="form-row-multi-22">
<div class="gcore-subinput-container" id="fitem-pinicial">
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-pinicial">
<input name="pinicial" id="pinicial" value="" placeholder="" maxlength="" size="6" class="validate['required','number'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /><span class="help-block">Printed Incial</span>
</div>
</div>
<div class="gcore-subinput-container" id="fitem-pfinal">
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-pfinal">
<input name="pfinal" id="pfinal" value="" placeholder="" maxlength="" size="6" class="validate['required','number'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /><span class="help-block">Printed Final</span>
</div>
</div>
<div class="gcore-subinput-container" id="fitem-tprinted">
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-tprinted">
<input name="tprinted" id="tprinted" value="" placeholder="" maxlength="" size="6" class="validate['custom:rekenen1'] form-control A" title="" style="" data-inputmask="" data-load-state="disabled" data-tooltip="" type="text" /><span class="help-block">Total Printed</span>
</div>
</div>
<div class="gcore-subinput-container" id="fitem-rinicial">
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-rinicial">
<input name="rinicial" id="rinicial" value="" placeholder="" maxlength="" size="6" class="validate['required','number'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /><span class="help-block">Remain Inicial</span>
</div>
</div>
<div class="gcore-subinput-container" id="fitem-rfinal">
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-rfinal">
<input name="rfinal" id="rfinal" value="" placeholder="" maxlength="" size="6" class="validate['required','number'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /><span class="help-block">Remain Final</span>
</div>
</div>
<div class="gcore-subinput-container" id="fitem-timpresas">
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-timpresas">
<input name="timpresas" id="timpresas" value="" placeholder="" maxlength="" size="6" class="validate['custom:rekenen2'] form-control A" title="" style="" data-inputmask="" data-load-state="disabled" data-tooltip="" type="text" /><span class="help-block">Total Impresas</span>
</div>
</div>
<div class="gcore-subinput-container" id="fitem-vendidas">
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-vendidas">
<input name="vendidas" id="vendidas" value="" placeholder="" maxlength="" size="6" class="validate['required','number'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /><span class="help-block">Vendidas</span>
</div>
</div>
<div class="gcore-subinput-container" id="fitem-mermas">
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-mermas">
<input name="mermas" id="mermas" value="" placeholder="" maxlength="" size="6" class="validate['required','number'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /><span class="help-block">Mermas</span>
</div>
</div>
<div class="gcore-subinput-container" id="fitem-cortesias">
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-cortesias">
<input name="cortesias" id="cortesias" value="" placeholder="" maxlength="" size="6" class="validate['required','number'] form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /><span class="help-block">Cortesias</span>
</div>
</div>
<div class="gcore-subinput-container" id="fitem-subtotal">
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-subtotal">
<input name="subtotal" id="subtotal" value="" placeholder="" maxlength="" size="6" class="validate['custom:rekenen3'] form-control A" title="" style="" data-inputmask="" data-load-state="disabled" data-tooltip="" type="text" /><span class="help-block">Subtotal</span>
</div>
</div>
<div class="gcore-subinput-container" id="fitem-responsable">
<div class="gcore-input pull-left gcore-sub-input gcore-display-table" id="fin-responsable">
<input name="responsable" id="responsable" value="" placeholder="" maxlength="" size="30" class="form-control A" title="" style="" data-inputmask="" data-load-state="" data-tooltip="" type="text" /><span class="help-block">Responsable</span>
</div>
</div>
</div>
</fieldset>
<div class="form-group gcore-form-row" id="form-row-button16">
<div class="gcore-input gcore-display-table" id="fin-button16">
<input name="button16" id="button16" type="submit" value="Submit" class="form-control A" style="" data-load-state="" />
</div>
</div>