Insert with Bootstrap Switch

Asked

Viewed 143 times

0

I am having a doubt in the following scenario, I am trying to insert the status using the plugin Plugin Link Here is a summary of the code I’m using

$status = $_POST['status'];

$stmt->bindParam("status", $status);
$stmt->execute();

<input type="checkbox"  id="destacar"  name="destacar"  value="sim" checked>

<script type="text/javascript"> $("[destacar='sim']").bootstrapSwitch(); </script>

My question is the following: How do I stop so that if the visual is off insert NO; and if I am on insert YES ?

  • Off-topic: Your selector $("[destacar='sim']") it seems wrong, I believe that the broker would be $("#destacar:checked"), destacar='sim' would process elements like <div destacar="sim"></div> and not the attribute value.

1 answer

0

solved the problem is just take the post and define it:

$destacar = (isset($_POST['destacar'])) ? 1 : 0;
$status = (isset($_POST['status'])) ? 1 : 0;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.