I've been using PHP, MS SQL, and HTML to build a tool for my work, I have most of it working but now I've built a report to be used with my data that I want to be able to write back to the database from on an onclick event of checkboxes. from the research I've done it suggests that I need to use Javascript to do this, I have basically no experience with Java. all of what I've found for tutorials show it when there is only one checkbox or if there are multiple it's something that is run after the fact.
The report I am trying to get to work writes 6 columns out for all database entries that do not have a date in the "sent" field and a checkbox, there may be 1 item, or there may be 200 of them at any given time. what I want is to click that checkbox and automatically trigger a PHP script that updates that line item with today's date in the sent column. my code is not right, I am certain I have glaring issues with how I have or am calling the script, but here is what I have.
Java:
<head>
<script src="http://ift.tt/rs8qB8"></script>
</head>
<script type="text/javascript">
function issent(cb){
if($(cb).is(":checked"))
{
$.getScript("sentscript.php?EID=33");
}
}
</script>
I've hardcoded the entry I'm trying to check off in the script for testing and it's still not working, ultimately I want EID=$EID[$i] (or the js equivalent since thats just how I'd use it in PHP)
PHP/HTML:
while($row = sqlsrv_fetch_array($result)) {
echo "<tr>
<td><input type='checkbox' onclick='issent(this)' name='sent[$i]' value='" . $row['EID'] . "'/></td>
</tr>";
$i ++;
}
this does nothing onclick, so I'm sure I've made a mess of it somewhere, but I can't figure out where and the questions I've read give little to no explanation and modifying the answers hasn't worked.
Aucun commentaire:
Enregistrer un commentaire