0

Is there a way where there is a number on the screen, for example 100, and a form where you can insert a number in the form and that number will be deducted from the one displayed.
So if i inserted 5, the number will become 100 and can there also be a reset button

as much as possible i want to do this with php and html only

4
Contributors
3
Replies
35
Views
8 Months
Discussion Span
Last Post by brothman01
1

How is this connected to your title? Are you asking if it.s possible to deduct a number in a form from another number. Yes. Shouldn.t your example then display 95? This can be done easily in js. Painful in php as a round trip to server and page reload required each time.

0

Painful in php as a round trip to server and page reload required each time.

This can be done easily in js.

I suggest do this as @diafol said

If you want to do this with only PHP and HTML, you have to submit your page on each actions, ie when you submit your number and reset your value. That takes to load page again and again. Try the below example:

<html>
<body>
<?php
$result = 100;
if(isset($_POST['hdnValue']) && isset($_POST['txtValue'])){
    $result = $_POST['hdnValue'] - $_POST['txtValue'];
}
?>
<h1><?php  echo $result; ?></h1>
<form action="#" method="post">
<input type="hidden" value="<?php  echo $result; ?>" name="hdnValue" />
<input type="text" name="txtValue" />
<input type="submit" value="Enter" />
</form>
<form action="" method="post" >
<input type="submit" value="Reset" />
</form>

</body>
</html>
0

lol that code above from @Bachu IS the answer to the question that was asked, but as @diafol pointed out, the question is in no way connected to the title, haha

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.