I have been trying to figure this out for two days and have had no luck.I am using PHP with Javascript and I am trying to access a Javascript variable on another Page.
Here is my Javascript code which is only alerting the user what taskID is...
<script>
function myFunction(taskID)
{
alert("Task #" + taskID);
}
</script>
Here is my PHP
//select all tasks for this report
$tasks = mysqli_query($conn,"SELECT taskID, hoursSpent, workDone, plannedTasks FROM Tasks where reportID = $report_id AND projID = $proj_id");
$task_count = 1;
while($row1 = mysqli_fetch_array($tasks))
{
$taskID = $row1['taskID'];
//display the task information
echo "<strong id='tasks'>Task #" . $task_count . "</strong>";
echo " - <a href = '#' onclick ='myFunction($taskID)'>Edit</a><br>";
echo "Hours Spent: " . $row1['hoursSpent'] . "<br><br>";
echo "Accomplished: <br>" . $row1['workDone'] . "<br><br>";
echo "Planned for Next week: <br>" . $row1['plannedTasks'] . "<br>";
echo "<br>";
$task_count++;
}
how can i pass that taskID to another page so i can edit the task information?
Thanks!
page?task=123? Doesn't that work for you?pushState/onpopstatestates, 4) in hash (theoretically part of URL, but not visible to server), or even in 5) session, 6)localStorageetc. - it all depends what exactly you are trying to achieve. I would however stick to using URL for this, if your pages are pretty static and you want to give the ability to open more than one at once.