我一直在試圖弄清楚這兩天,並沒有運氣。我正在使用PHP與Javascript,我想訪問另一頁上的JavaScript變量。將Javascript或PHP變量傳遞到另一頁
這裏是我的Javascript代碼這是隻有提醒用戶什麼樣的taskid是...
<script>
function myFunction(taskID)
{
alert("Task #" + taskID);
}
</script>
這是我的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++;
}
我怎麼能傳遞任務id到另一個頁面,所以我可以編輯任務信息?
謝謝!
最簡單的GET變量:「mysite的。 com/otherpage.php?taskID = 3「 – winkbrace
Erm,鏈接到'page?task = 123'?這不適合你嗎? –
location =「nextpage.php?task =」+ taskId – mplungjan