I asked a question last week that turned out to be entirely my mistake in a section I assumed to be correct, but once the primary issue was resolved I am still left unable to get my line variable to my Javascript code. I have no actual experience with Javascript unfortunately and all tutorials or answered questions I find only show me how to get a specific checkbox to my Javascript, not one from a variable line.
Here is what I am trying to do, I have a report running with PHP from my SQL server database which reports every item without a sent date, this could be hundreds of items at a time, each line has some information about the unsent item and a checkbox, the checkbox has an "onclick" event to call my Javascript, which calls a PHP page and writes a sent date to the database for that item.
The current code works if I hard code an EID into my PHP link, so everything except passing a variable has been tested and works. Here is my code:
PHP
while($row = sqlsrv_fetch_array($result)) {
echo "<tr>
<td><a href='vieweid.php?EID=" . $row['EID'] . "'>view</a></td>
<td><input type='checkbox' onclick='issent(this)' name='sent[$i]' value='" . $row['EID'] . "'/></td>
</tr>";
$i++;
}
Javascript:
<script type="text/javascript">
function issent(cb){
if($(cb).is(":checked"))
{
var jsEID = $(this).val()
$.getScript("sentscript.php?EID="jsEID);
}
}
</script>
I'm not certain if the variable is not being filled in JS or if I'm calling it incorrectly as part of my $.getscript. Any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire