I want to display result of addition of two number from two text box into third text box. the code must write in php script. i mean how do i assign value of variable to textbox dynamically.
Add two number from two textbox and disply result in third text box
Collapse
X
-
use post,
example: $_POST['textbox1']
read this: http://www.html-form-guide.com/php-f...form-post.html
#tip -
You could also use JavaScript. If it's a simple little form, you can do something like:
And then the form should be something like:Code:<script> function getText3(){ var in1=document.getElementById('in1').value; var in2=document.getElementById('in2').value; var in3=in1+in2; document.getElementById('in3').value=in3; } </script>
Thoughts?Code:<form> <input type="text" id="in1"/> <input type="text" id="in2"/> <input type="text" id="in3"/> <button type="button" onclick="getText3()">Get text 3</button> </form>Comment
-
simple form
<html>
<head>
<title>My Page</title>
</head>
<body>
<br>
<form name="myform" action="textent ry2.php" method="POST">
<input type="submit" name="submit" value = "go">
<input type="text" name="text1" onkeyup="calc() ">
<input type="text" name="text2" onkeyup="calc() ">
<input type="text" name="text3" >
</form>
<script>
function calc()
{
var elm = document.forms["myform"];
if (elm["text1"].value != "" && elm["text2"].value != "")
{elm["text3"].value = parseInt(elm["text1"].value) - parseInt(elm["text2"].value);}
}
</script>
</body>
</html>Comment
Comment