3
我試圖通過cfm頁面傳遞唯一的數據庫會話ID,但似乎無法得到它的工作。第1頁有記錄ID,即時試圖保存在recordclick()函數的numSession中,並將其傳遞到下一頁,我在查詢中使用它,但它不起作用。簡單的coldfusion傳遞記錄id到JS函數?
下面有什麼即時通訊做一個大致的輪廓:
第1頁:
<CFQUERY datasource = "database1" result = "result">
insert into user
set
blah blah
</cfquery>
<html>
<head>
<title>page1</title>
<script type="text/javascript">
function recordClick(imageid)
{
document.getElementById("numSend").value = document.getElementById("numSend").value + imageid;
document.getElementById("numSession").value = result.generated_key;
}
</script>
</head>
<body>
<FORM action="page2.cfm" method="post">
<img src="1.png" NAME="num1" onclick="recordClick(1)"
width="100px"
height="100px">
<div name="num1" id="num1"></div>
<input type="hidden" id="numSend" name="numSend" />
<input type ="hidden" id = "numSession" name ="numSession" />
<input type="submit" value="Done" />
</form>
</body>
</html>
--------------------------------------
<cfoutput>
The ID of the row I just inserted was "#numSession#"
</cfoutput>
<CFQUERY datasource = "database1">
update user
set
pin = "#numSend#"
where id= "#numSession#"
</cfquery>
謝謝,但看的時候我嘗試輸出變量在第二頁它似乎沒有工作。第二頁:#numSession# –
user1228554
2012-02-23 16:21:31
你將不得不比'看起來沒有工作'更具體# – 2012-02-23 16:27:14
@ user1228554,我已經更新了JS函數以包含''標籤。這是否解決了你的問題? –
2012-02-23 17:25:56