NAVIGATION
This shows you the differences between two versions of the page.
|
english:phpwcms-system:article:contentparts:form:special-applications:inner-field-calculation [2009/04/25 08:06] 127.0.0.1 external edit |
english:phpwcms-system:article:contentparts:form:special-applications:inner-field-calculation [2018/06/03 18:09] (current) |
||
|---|---|---|---|
| Line 7: | Line 7: | ||
| - | Re: Kann man mit Formularfeldern rechnen? | + | Re: Is there a way to calculate with form fields? |
| Posted by Oliver Georgi on Tue Dec 16, 2008 18:30 \\ | Posted by Oliver Georgi on Tue Dec 16, 2008 18:30 \\ | ||
| - | Ein einfacher Weg so etwas zu realisieren, ist die Nutzung von (ganz exemplarisch): | + | A simple approach how to get this going is making use of (just an example): |
| - | a) 1 x hidden Feld (hidden_field_name) im Formular -> das ist das Ziel der Berechnung und kann demzufolge dann als Wert in das Mailformular übernommen werden. | + | a) 1 x hidden field (hidden_field_name) within your form -> this will be the target for your calculation and will be taken over into your mail form then. |
| - | b) dazu dann ein frontend_init Script "my_form_init.php": | + | b) additionally a frontend_init script "my_form_init.php": |
| <code php> if(isset($_POST['fieldname'])) { | <code php> if(isset($_POST['fieldname'])) { | ||
| Line 38: | Line 38: | ||
| {{:deutsch:andere-erweiterungen:form.jpg|}} | {{:deutsch:andere-erweiterungen:form.jpg|}} | ||
| - | > Erstelle dir die Datei ##/template/inc_script/frontend_init/check.php## | + | > Create the file ##/template/inc_script/frontend_init/check.php## |
| <code php> | <code php> | ||
| <?php | <?php | ||
| if(isset($_POST['eingabe'])) { | if(isset($_POST['eingabe'])) { | ||
| - | // hier die Berechnung durchführen - an der Stelle ganz beispielhaft realisiert. | + | // do your calculation here - this is an example. |
| $_POST['versteckt'] = xss_clean($_POST['eingabe']) * 1000; | $_POST['versteckt'] = xss_clean($_POST['eingabe']) * 1000; | ||
| } | } | ||
| ?> | ?> | ||
| </code> | </code> | ||
| - | > Jetzt kannst du deine Berechnungen durchführen. | + | > Now you can do your calculations. |
| - | > Zur Zeit wird der Inhalt des Feldes "eingabe" mit 1000 multipliziert, angezeigt wird der Eingabewert und das Ergebnis. | + | > In our example the field input is multiplied by 1000, while the output is showing the input value and the result. |
| > | > | ||
| - | > Dem versteckten Feld (hidden) einen Standardwert mitgeben. Das Feld als Pflichfeld im CP definieren. | + | > Insert a default for the hidden field (hidden). Define this field as "required". |
| - | > //(Bei Fehler in der Berechnung Feldwert auf "" ($_POST['my_hidden_field'] = "";) setzen).// | + | > //(If an error is encountered, set the field value to "" ($_POST['my_hidden_field'] = "";) ).// |
| > | > | ||
| - | > Ergebnis: Fehlermeldung -> ist das Ergebnis gültig, hat auch der hidden Feldwert das gültige Ergebnis. | + | > Result: Error -> if the value is validating, then the hidden field value will too contain the valid result. |