Creating a form to input numbers using plus sign and negative sign.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ciro07
    New Member
    • Mar 2015
    • 3

    Creating a form to input numbers using plus sign and negative sign.

    Im doing a small project at work. This needs an input form that accepts only (+) plus (-) minus, with a resulting out put of 1 for plus and 0 (zero) for minus.
  • Exequiel
    Contributor
    • Jul 2012
    • 288

    #2
    Try this code.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Positive Negative Zero</title>
    </head>
    
    <body>
    <form method="post">
    <input type="text" placeholder="Input Number" name="input" value="<?=$_POST['input']?>">
    <input type="submit" name="submit">
    </form>
    
    <?php 
    if(isset($_POST['submit']))
    {
    	$input = $_POST['input'];
    			
    	if($input>0)
    	{
    		echo 'Your input is Positive';
    	}			
    	else if($input<0)
    	{
    		echo 'Your input is Negative';
    	}		
    	else if($input==0)
    	{
    		echo 'Your input is Zero';
    	}
    }
    ?>
    </body>
    </html>

    Comment

    • MonicaM
      New Member
      • Mar 2015
      • 1

      #3
      Please clarify your question more clearly as you want code to built a form in which language HTML or any other. so that I will help you out.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        you want code to built a form in which language HTML or any other.
        is there any form that does not consist of HTML?

        Comment

        • ciro07
          New Member
          • Mar 2015
          • 3

          #5
          I need to create a using HTML, Im just a beginner and trying to teach
          myself, html and php. thanks in advance.

          Comment

          • ciro07
            New Member
            • Mar 2015
            • 3

            #6
            what I had tried to ask, was I create a form to be used in science project, where results are entered as either positive
            or negative. But the out put should generate the 1 for positive and the number 0 (zero) for negative.
            Not sure if that tries to explain my reasoning.

            Thanks

            Comment

            Working...