Jump to content

Onclick checkbox that inserts data into a Database


law

Recommended Posts

How can i make an onclick checkbox that inserts data into my database?

all i want is for the checkbox upon being clicked to change the value of my picks column in my database between 1 and 0. 1 if the box is checked and 0 if it is not. Here is the query that selects the column i wish to edit. "SELECT paid FROM members WHERE id = "$id""

I literally know nothing about javascript so im looking for the exact code or some good explanation.. because if i have to edit the code myself there is a 50% chance i will screw it up! thanks guys! i appreciate your time

 

Well first off your using the mysql; you need to be using UPDATE. Then you will have to add an onclick event to a checkbox that will submit your form variable values to you php/mysql.

 

something like:

 

<script language="javascript">
function addinfo()
{
document.msqlfs.submit();
}
</script>

I have been here:<br><br>

<form name="msqlfs" action="myphpandmysqlpage.php" method="post">
<input type="checkbox" name="checkboxnamehere" value="0" onclick="addinfo()"> Never
<input type="checkbox" name="checkboxnamehere" value="1" onclick="addinfo()"> Once
</form>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.