checkbox- if statement

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DavidOwens
    New Member
    • Mar 2007
    • 56

    checkbox- if statement

    Yo Yo Yo, hey guys

    lol a tricky question for my limited php skills, lol but i bet you will be laughin your head of when i ask about it.

    i have a form that asks users to fil out information about stock, its got loads of checkbox's with YES or No options.

    so they fil in the form, e.g do you have blue walls YES or No, say no is checked, then no is displayed,

    so my code says this


    is wall blue? $checkbox1 ,

    but that only gives me the option to display 1 answer, which in this case would always be YES, so how do i go about going the if statement to see which box has been checked?
  • exoskeleton
    New Member
    • Sep 2006
    • 104

    #2
    hi sir...i think you may use radio button coz if check box you can check both YES and NO.

    then the radio button have the same name of course in order to choose one of them. then for example radio button :

    [HTML]<form name="form1" method="post" action="">
    <input type="radio" name="radiobutt on" value="YES">
    <input type="radio" name="radiobutt on" value="NO">
    </form>[/HTML]

    upon submit for example:

    [PHP]$radiobutton = $_POST['radiobutton'];

    if ($radiobutton== 'YES') {

    echo "YES";

    } else {

    echo "NO";

    }[/PHP]
    thats only and example ... hope this helps...

    Comment

    • DavidOwens
      New Member
      • Mar 2007
      • 56

      #3
      Originally posted by exoskeleton
      hi sir...i think you may use radio button coz if check box you can check both YES and NO.

      then the radio button have the same name of course in order to choose one of them. then for example radio button :

      [HTML]<form name="form1" method="post" action="">
      <input type="radio" name="radiobutt on" value="YES">
      <input type="radio" name="radiobutt on" value="NO">
      </form>[/HTML]

      upon submit for example:

      [PHP]$radiobutton = $_POST['radiobutton'];

      if ($radiobutton== 'YES') {

      echo "YES";

      } else {

      echo "NO";

      }[/PHP]
      thats only and example ... hope this helps...
      thank you :)

      Comment

      • exoskeleton
        New Member
        • Sep 2006
        • 104

        #4
        No problem sir... :D

        But you must help me when I am in need. hehehe :D

        Comment

        Working...