如果选中复选框,则擦除值

I would like the following:

Data = "123";
if checkbox clicked {Data="";}

Submit-button


That was the best way I could explain it.

I have tried, but I can't get the checkbox to overwrite the data with an empty value.

<form action="form.php" method="post">
<input type="text" value="" name="data" />
<input type="checkbox" value="checkbox" name="checkbox" />
<input type="submit" value="Submit" name="submit" />
</form>

That is your form, and this is your PHP

<?php
if(isset($_POST['submit']))
{
    if(isset($_POST['checkbox']))
    {
         $_POST['data'] = "";
    }
    /* the rest of your form */
}
?>