Hello everybody
I have a function that change a text when i change a checkbox of the form
...
(* 'num' now is no used ...)
That change this text...
when ...
Everything is okey, but when validation fails, and come back to form with all values selected and included, the "txt span" come back to default initial "170" without seeing actual value of checkbox ...
¿How can i load the javascript event when validation fails?
Thank you very much
I have a function that change a text when i change a checkbox of the form
...
function descontar(chk,ide,num) {
obj = document.getElementById(ide);
obj.innerHTML = (chk.checked ? 110 : 170)
}
...(* 'num' now is no used ...)
That change this text...
<input id="tipo" name="tipo" type="radio" value="NORMAL" checked="checked"/>
Inscripción ordinaria <span id="txt">170</span>€</td>
</td>when ...
<input name="asturiano" id="asturiano" type="checkbox" value="SI" onclick = "descontar(this,'txt',60);"> Asturiano?</td>Everything is okey, but when validation fails, and come back to form with all values selected and included, the "txt span" come back to default initial "170" without seeing actual value of checkbox ...
¿How can i load the javascript event when validation fails?
Thank you very much
I have found a solution i think
At the end of the form I check if i have a post value and re-execute the javascript
It seems to work.
Thank you very much ... any suggestion?
At the end of the form I check if i have a post value and re-execute the javascript
<?php if(isset($_POST['asturiano'])) {
?>
<script type="text/javascript">
descontar(document.getElementById("asturiano"),'txt',0);
</script>
<?php
}
?> It seems to work.
Thank you very much ... any suggestion?
Hi jaem15,
That should work OK.
Otherwise you need to add the calculated value into a hidden form input so that it is submitted with the form. Then you can recover it in the Form HTML and re-use it.
If you don't save and submit the value then you need to recalculate as your script does.
Bob
That should work OK.
Otherwise you need to add the calculated value into a hidden form input so that it is submitted with the form. Then you can recover it in the Form HTML and re-use it.
If you don't save and submit the value then you need to recalculate as your script does.
Bob
This topic is locked and no more replies can be posted.
