I have made a select code to update my database with:
<form method="post" action="<?php $_PHP_SELF ?>">
<table><tr><td style="border:1px solid #000;">
<select name="priv" id="priv">
<option value="<?php echo $pinDetails->is_private; ?>">(<?php echo $pinDetails->is_private; ?>)</option>
<option value="1">Private (1)</option>
<option value="0">Public (0)</option>
</select>
<input name="private" type="submit" id="private" value="Private">
</td></tr></table>
</form>
This basically allows me to change a post from public to private by selecting the appropriate option in the list. It displays the current value as the first option.
However, this code looks messy and I know the function could probably to achieved a way better way than clicking an option, something along the lines of a button which I can switch on or off like a switch?
What would I need to search for or what type of code would work for this? I'm more than willing to write the code myself given a point in the right direction.
You can use whatever you want, ie often programmers use radio buttons and style them like a switch.
Maybe this could be of interest: http://proto.io/freebies/onoff/
Also check this jsFiddle :
<div>
<input type="checkbox" id="switch1" name="switch1" class="switch" />
<label for="switch1">First switch</label>
</div>
<div class="clear"> </div>
<div>
<input type="checkbox" id="switch2" name="switch2" class="switch" />
<label for="switch2">Second switch</label>
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.