好的,我對Coldfusion(和StackOverflow)還是比較新的,需要一些幫助。所以我有一個cfquery,它將從數據庫中提取值並將它們輸出到cftextarea。從數據庫返回的每個值都有自己的cftextarea。在按鈕上展開cftextarea點擊
<script type=text/javascript>
function expand(){
if (document.getElementById("report").style.width == "1000px"){
document.getElementById("report").style.width = "222.5px";
document.getElementById("report").rows = "1";
}
else{
document.getElementById("report").style.width = "1000px";
document.getElementById("report").rows = "15";
}}
</script>
<cfquery name="getvalues">
SELECT * FROM STUDENT
</cfquery>
<cfset noVals = '#getvalues.recordCount#'>
<cfform>
<!--- find number returned from query, loop number of times, creating a new text area and checkbox each time ---->
<cfloop query="getvalues" startRow=1 endRow="#noVals#">
<cfinput type="checkbox" name="selectedReport">
<cftextarea name="report" rows="1" cols="25">
<cfoutput>
SID: #SID#
GRADE: #GRADE#
FINAL SCORE: #FINAL#
</cfoutput>
</cftextarea>
<img src="assets/images/expand.png" width="35" height="35" style="vertical-align: top;" onclick="expand();">
<br>
</cfloop>
</cfform>
我需要知道如何通過點擊它們旁邊的圖像來擴展這些cftextareas(最好用javascript)。如果cftextarea是它的原始大小,我希望它擴大。如果它被展開,我希望它縮回到默認大小。任何幫助將不勝感激,我迄今爲止做的唯一的事情是擴大和縮小頂部cftextarea。
你沒有元素的ID爲'report',所以你的JavaScript不會做任何事情。你需要'' –
我會強烈建議丟棄的ColdFusion特定的標籤和使用HTML,文本區域等 –
此外,文本區域的*編輯*數據時更合適。如果這是此表單設計的目標,則最好爲這三個值中的每一個使用單獨的字段。注意,cfloop看起來過於複雜。要輸出查詢中的所有記錄,只需使用' ..在這裏做東西.. ' –
Leigh