Welcome Guest, Not a member yet? Register   Sign In
how to modify a text field on a form
#1

(This post was last modified: 01-20-2021, 06:05 AM by richb201.)

I have a text field on a form:
<?php
echo "<br><br><br><br><br><br><h3>Report for:  ".$_SESSION['campaign']." for tax year ended ".$_SESSION['last_TY'];
?>


Then I have the rest of the page:
<form method="post">
    <?php
    $taxyear=$_SESSION['last_TY'];
\koolreport\inputs\Select::create(array(
    "name"=>"taxyear",
    "data"=>$_SESSION['TY'],  //this is a list of years in an array
    "defaultOption"=>array($taxyear=>''),
));
    ?>
    <button type="submit">Submit</button>
</form>


here is where I am trying to get the user's input:
<?php
if (isset($_POST['taxyear']))
    $_SESSION['last_TY']=$_POST['taxyear'];
?>


Plus a whole report. 

After a user presses the submit button, I'd like to update the for tax year ended ".$_SESSION['last_TY'] in the text field. 

But I am finding that the $_SESSION['taxyear'] is not getting updated as I thought it would. It seems to be delayed until I press submit a 2nd time. Each time they hit submit, the entire page is run (which is good) but I need to set the $taxyear before running it. I have set up a default taxyear in $_SESSION['tax_year'] in my controller that gets used the first time they display the form. 

How do I get the submit button to control this thing (except the first time, when it should use the default I have set)? What I would like is for a user to pick a tax year from $_SESSION['TY'] list, update Report for:  ".$_SESSION['campaign']." for tax year ended ".$_SESSION['last_TY'];, and then rerun the page with the new $taxyear, 
proof that an old dog can learn new tricks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB