I've in the first page two Text Fileds populated wiht data read from a DB table.
Then in a second page I need to multiply the value of the two fileds in the first page and put in a Text Field of the second page.
I've tested using Javascript, that works fine with the field values on the active page, but it seems that is not able to read filed value of the first page.
Here the Javascript:
var txtRetribuzioneLordaValue = document.getElementById('field_retribuzione_lorda').value;
var txtDivisoreValue = document.getElementById('field_divisore').value;
var txtMoltiplicatoreValue = document.getElementById('field_moltiplicatore').value;
var txtImportoMedioOraStraordinariaFloat = parseFloat(txtRetribuzioneLordaValue) / parseFloat(txtDivisoreValue) * parseFloat(txtMoltiplicatoreValue);
var txtImportoMedioOraStraordinaria = txtImportoMedioOraStraordinariaFloat.toFixed(2);
document.getElementById('field_importo_medio_ora_straordinaria').value = txtImportoMedioOraStraordinaria; (OK Works fine because all in second page)
var txtPercorrenzaMediaMensileKmValue = document.getElementById('field_percorrenza_media_mensile_km').value;
var txtEuroKmValue = document.getElementById('field_euro_km').value;
var txtTrasfertaMensileFloat = parseFloat(txtPercorrenzaMediaMensileKmValue) * parseFloat(txtEuroKmValue);
document.getElementById('field_trasferta_mensile').value = txtTrasfertaMensileFloat; (NOT OK! Because the elements are in the first page)
Thanks for support.
Then in a second page I need to multiply the value of the two fileds in the first page and put in a Text Field of the second page.
I've tested using Javascript, that works fine with the field values on the active page, but it seems that is not able to read filed value of the first page.
Here the Javascript:
var txtRetribuzioneLordaValue = document.getElementById('field_retribuzione_lorda').value;
var txtDivisoreValue = document.getElementById('field_divisore').value;
var txtMoltiplicatoreValue = document.getElementById('field_moltiplicatore').value;
var txtImportoMedioOraStraordinariaFloat = parseFloat(txtRetribuzioneLordaValue) / parseFloat(txtDivisoreValue) * parseFloat(txtMoltiplicatoreValue);
var txtImportoMedioOraStraordinaria = txtImportoMedioOraStraordinariaFloat.toFixed(2);
document.getElementById('field_importo_medio_ora_straordinaria').value = txtImportoMedioOraStraordinaria; (OK Works fine because all in second page)
var txtPercorrenzaMediaMensileKmValue = document.getElementById('field_percorrenza_media_mensile_km').value;
var txtEuroKmValue = document.getElementById('field_euro_km').value;
var txtTrasfertaMensileFloat = parseFloat(txtPercorrenzaMediaMensileKmValue) * parseFloat(txtEuroKmValue);
document.getElementById('field_trasferta_mensile').value = txtTrasfertaMensileFloat; (NOT OK! Because the elements are in the first page)
Thanks for support.
Hi ranton,
JavaScript only works in the browser and the results are not carried back to the server, and so are not available on the next page.
If I understand what you are doing here correctly the simplest solution is probably to use PHP in the second page load to do the multiplication and add the result to the form data before the second page loads.
Bob
JavaScript only works in the browser and the results are not carried back to the server, and so are not available on the next page.
If I understand what you are doing here correctly the simplest solution is probably to use PHP in the second page load to do the multiplication and add the result to the form data before the second page loads.
Bob
You need to login to be able to post a reply.