2013-06-26 38 views
-1

我有在模板工具包文件的代碼:想通過從模板工具包文件變量CGI腳本

<html> 
<head> 
<title>test</title> 
<script type="text/javascript"> 
var counter = 0; 
function addNew() { 
// Get the main Div in which all the other divs will be added 
var mainContainer = document.getElementById('mainContainer'); 
// Create a new div for holding text and button input elements 
var newDiv = document.createElement('div'); 
// Create a new text input 
var newText = document.createElement('input'); 
newText.type = "input"; 
//newText.value = counter; 
// Create a new button input 
var newDelButton = document.createElement('input'); 
newDelButton.type = "button"; 
newDelButton.value = "Delete"; 
// Append new text input to the newDiv 
newDiv.appendChild(newText); 
// Append new button input to the newDiv 
newDiv.appendChild(newDelButton); 
// Append newDiv input to the mainContainer div 
mainContainer.appendChild(newDiv); 
// counter++; 
// Add a handler to button for deleting the newDiv from the mainContainer 
newDelButton.onclick = function() { 
mainContainer.removeChild(newDiv); 
} 
} 
</script> 
</head> 

<body > 
<form name="group_save" method="post" action="process.cgi"> 
<div id="mainContainer"> 
<div><input type="button" value="Add" onClick="addNew()"></div> 
</div> 
<div><input type = "submit" value = "Save"></div> 
</form> 
</body> 
</html> 

我想文本框的值傳遞給CGI文件處理。 cgi將其插入數據庫。

代碼在process.cgi:

​​

但在檢查中,我發現,價值不是在這個過程中得到頁。 請幫我解決這個問題。

+0

什麼文字區? HTML中沒有文本區域。你有兩個輸入 - 一個按鈕和一個提交。 –

+0

不是文本區域....我有文本框,它將在java腳本調用上創建。我還將爲其添加代碼。 –

回答

1

你得到的參數與此代碼:

my $grupsave = $cgi->param("group_save"); 

但在名爲「group_save」你的表格沒有HTML的輸入。您使用JavaScript創建的文本輸入沒有名稱,因此其內容不會傳遞給您的CGI程序。

您需要給文本框命名爲「group_save」。