Page 1 of 1

Form: POST a string & get the result in the same form field

Posted: Thu Dec 23, 2010 11:08 am
by easyrider767
Is to possible to POST a string in the form field and get converted string result in the same form field?

I use the code:

Code: Select all

<?php
  $string='';
  if (isset($_POST['string']))
    $string=$_POST['string']

  if (isset($_POST['DoStuff']))
  {
    $string = doStuffWithThisString($string);
  }
  if (isset($_POST['DoOtherStuff']))
  {
    $string = doOtherStuffWithThisString($string);
  }

?>

<form action="" method="post">
<!-- blank action attribute will post form to the current page-->
  <input type="text" value="<?=$string?>" name="string" />
<!-- <?=$string?>  is the same as <?php echo $string; ?> -->
  <input type="submit" value="Do Stuff" name="DoStuff" />
  <input type="submit" value="Do Other Stuff" name="DoOtherStuff" />
</form>
but get the result above form field

Re: Form: POST a string & get the result in the same form fi

Posted: Thu Dec 23, 2010 8:04 pm
by anantha
what do u mean u get above form field? u need to pass the $string to the value..if for example, if it is a text box..

Re: Form: POST a string & get the result in the same form fi

Posted: Thu Dec 23, 2010 9:09 pm
by califdon
Have you tried it? What do you get?