Forums

Is it possible to change a value before POST

Raymon 12 Feb, 2008
Hi There,

Is it possible to change the value to something different before posting it?

For example:
Choose prioritiy:<select name="prio">
 <option>1</option>
 <option>2</option>
 <option>3</option></select>


User chose 1, now i need to send a mail where the receiver expects diferent values.

value=1

1 corresponds to LowPRIORITY

So the mail would be:
prio: LowPRIORITY
instead of
prio: 1

Can somebody give me a hand with the php in on submit before mail?

Thnx!
Raymon
Max_admin 12 Feb, 2008
Hi Royman,

You can use the email template field with some PHP OR you can use some Javascript function to change a hidden field value upon changing the dropdown values by the user!

For the PHP solution, you can put this in the email template and take care to put teh PHP tags :


Hey, the user set the priority to : <br>
<?php
if($_POST['prio'] == 1){echo "LOW"};
if($_POST['prio'] == 2){echo "Normal"};
if($_POST['prio'] == 3){echo "High"};
?>
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
GreyHead 12 Feb, 2008
Hi Raymon,

Personally I prefer the Switch version of this:
<?php
switch ( $_POST['prio'] ) {

case 1:
  $message = "Low";
  break;
case 2:
  $message = "Normal";
  break;
case 3:
default:
  $message = "High";
  break;
}
echo $message;
?>
It's more elegant than using multiple ifs and much easier to read when the code blocks get longer. Does the same thing though.

Bob<br><br>Post edited by: GreyHead, at: 2008/02/13 00:58
Raymon 12 Feb, 2008
This is good tested it and it works like a charm!!!

Thnx guys!
This topic is locked and no more replies can be posted.