I have the following PHP code which is a template page for a wordpress site:
<?php
/*
Template Name: Calculator Form
*/
get_header(); ?>
<div id="content" class="grid_7 suffix_1 <?php echo of_get_option('blog_sidebar_pos') ?>">
<FORM action="<?php bloginfo('template_directory'); ?>/function.php" method="post">
<INPUT TYPE="text" NAME="inputbox" VALUE="" style="width:200px;" />
<INPUT TYPE="button" NAME="button" Value="Calculate" style="width:200px;" />
<INPUT TYPE="text" NAME="result" VALUE="" disabled style="width:200px;" />
</FORM>
</div><!--#content-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
For arguments sake, let's say that the function.php file looks like:
<?php
function calculate($value)
{
return $value / 1000;
}
calculate($_POST['inputbox']);
?>
I want to add the result of this function into the result field in the form.
functions.php
or in a plugin file. The Javascript would be in a.js
file of your creation. – s_ha_dum Aug 13 '13 at 23:56