Note that there are some explanatory texts on larger screens.

plurals
  1. POHTML reset button not working properly
    primarykey
    data
    text
    <p>I have a basic sum example with some <code>PHP</code> and <code>HTML</code>, inside this <code>PHP</code> page the reset button only resetting first two input field, and it is not resetting the third answer field. I dont know what is the error with this cause i am new to <code>PHP</code>. someone please help me to fix this.</p> <p><strong>code</strong></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Title goes here&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="" method="post"&gt; &lt;label&gt;Enter Num1:&lt;/label&gt; &lt;input type="text" name="num1" id="num1" /&gt;&lt;br&gt; &lt;label&gt;Enter Num2:&lt;/label&gt; &lt;input type="text" name="num2" id="num2" /&gt;&lt;br&gt;&lt;br&gt; &lt;input type="radio" name="rad" value="add"/&gt;addition &lt;input type="radio" name="rad" value="sub"/&gt;sub &lt;input type="submit" name="btn_submit" value="fire"&gt; &lt;?php if(isset($_POST['btn_submit'])) { $num1 = $_POST['num1']; $num2 = $_POST['num2']; $rad_val = $_POST['rad']; if($rad_val=="add"){ $total = $num1+$num2; } else if($rad_val=="sub"){ $total = $num1-$num2; } echo "&lt;SCRIPT TYPE=\"text/javascript\"&gt; document.getElementById(\"num1\").value= $num1; document.getElementById(\"num2\").value= $num2; &lt;/SCRIPT&gt;"; echo "&lt;label&gt;Answer is:&lt;/label&gt; &lt;input type=\"text\" name=\"rad\" value = $total /&gt;"; echo"&lt;input type=\"reset\" name=\"reset\" value=\"reset\" /&gt;"; } else if(isset($_POST['reset'])){ echo "&lt;script&gt;window.location = 'your_page.php';&lt;/script&gt;"; } ?&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload