Welcome to WebmasterWorld Guest from 54.167.78.17

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

textfield1+textfield2

     
8:49 pm on Dec 9, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Nov 16, 2008
posts:136
votes: 0


is there a way to make an addition with two text field with the values that they have in them.
Example if my textfield1 contain 1 and the textfield2 contain 3 i would like to have the result 4 in a textfield3.
10:09 am on Dec 10, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 24, 2005
posts:697
votes: 0


<?php
$result=floatval($_REQUEST["textfield1"])+floatval($_REQUEST["textfield2"]);
?>

<input type="text" name="textfield3" id="textfield3" value="<?php =$result;?>">
5:41 pm on Dec 10, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Feb 22, 2009
posts:1396
votes: 0


Hi all,

Unless I misunderstand the context of this, I would urge you to substitute the _REQUEST for _POST, this is purely for a more secure approach, but if this is just for development, you should be fine, but honestly try not to use _REQUEST on a live server as you will reveal lots of information about your site.

Cheers,
MRb
12:25 pm on Dec 12, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 24, 2005
posts:697
votes: 0


Yep makes sense, just that i didnt know what his form submission method was and i didnt want to post something that won't work for him when he tries