1

I've got this :

<form action="index.php" method="get">
     <input  type="checkbox" name="Convs_revenue"
      <? echo (isset($_GET['extra_Data'])?"value='yes'":"value='no'");?>  
      <? if (isset($_POST['extra_Data']) ) echo 'checked="checked"'; ?> >extra_Data </input>
      <input type="submit" value="send">
</form>

Now I need to keep the value of tp keep the value of the checkbox, and to unset it when its unchecked. I MUST use the GET method for this form, and this need to be at the same page as well.

What happen is that its always seem to be checked no matter what I do, and the get array always keep this at on...

BenMorel
  • 34,448
  • 50
  • 182
  • 322
Meta_data
  • 558
  • 3
  • 14

1 Answers1

1

Well for a start, <input /> needs no closing tag. I've also tidied up the code a little so it's a bit more readable.

I've added an extra check to make sure $_POST['extra_Data'] isn't empty. It will show up as set if it is posted empty somehow, I can't see how you're generating the POST itself.

<form action="index.php" method="get">
     <input name="Convs_revenue" type="checkbox" value="<?php (isset($_GET['extra_data']) ? 'yes':'no'); ?>" <?php (isset($_POST['extra_Data']) && !empty($_POST['extra_Data'] ? 'checked="checked"' : '') ?> />
     <input type="submit" value="send">
</form>
Tom Hallam
  • 1,924
  • 16
  • 24