私は別のjqueryテーブルのレコードをクリックすると生成されるjqueryのテーブルを持っています。このテーブルのレコードには、入力して提出するデータがあります。テーブルはいくつかのレコードで構成されています。送信ボタンをクリックすると、表にある各レコードは、レール・データベース表の別個のレコードでなければなりません。どのように私は必要なデータを取得し、データベースに提出する。私はテーブルの作成メソッドが必要だが、私はどのように属性を割り当てるか分からないことを知っている。データは複数のレコードをJQueryからRailsテーブルに保存しますか?
に保存する必要がある場合のプロジェクト一覧表
<div class="right">
<b>Projects this week</b><div class = "right"><input name="btnDel" type="button" id="btnDel" value="-" onClick="RemoveRow();"></div>
<ul id="task_list">
<form name="frmMain" method="post">
<table width="470" border="1" id="tbExp">
<tr>
<td><div align="center">No.</div></td>
<td><div align="center">Project </div></td>
<td><div align="center">Task </div></td>
<td><div align="center">Hours </div></td>
<td><div align="center"></div></td>
</tr>
</table>
<input type="hidden" name="hdnMaxLine" value="0">
</form>
</ul>
</div>
Javscriptプロジェクト一覧表
function CreateSelectOption(ele) {
var objSelect = document.getElementById(ele);
var Item = new Option("", "");
objSelect.options[objSelect.length] = Item;
var Item = new Option("Pre-Sales");
objSelect.options[objSelect.length] = Item;
var Item = new Option("Project");
objSelect.options[objSelect.length] = Item;
var Item = new Option("Support");
objSelect.options[objSelect.length] = Item;
}
function CreateNewRow(num, str) {
var intLine = parseInt(document.frmMain.hdnMaxLine.value);
intLine++;
var theTable = document.getElementById("tbExp");
var newRow = theTable.insertRow(theTable.rows.length)
newRow.id = newRow.uniqueID
var newCell
//*** ID Column ***//
newCell = newRow.insertCell(0);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = num;
//*** Column 1 ***//
newCell = newRow.insertCell(1);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
//newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"10\" NAME=\"Column1_"+intLine+"\" ID=\"Column1_"+intLine+"\" VALUE=\"\"></center>";
newCell.innerHTML = str;
//*** Column 2 ***//
newCell = newRow.insertCell(2);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><SELECT NAME=\"Column5_"+intLine+"\" ID=\"Column5_"+intLine+"\"></SELECT></center>";
//*** Column 3 ***//
newCell = newRow.insertCell(3);
newCell.id = newCell.uniqueID;
newCell.setAttribute("className", "css-name");
newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column4_" + intLine + "\" ID=\"Column4_" + intLine + "\" VALUE=\"\"></center>";
//*** Column 4 ***//
// newCell = newRow.insertCell(3);
// newCell.id = newCell.uniqueID;
// newCell.setAttribute("className", "css-name");
// newCell.innerHTML = "<center><INPUT TYPE=\"TEXT\" SIZE=\"5\" NAME=\"Column4_"+intLine+"\" ID=\"Column4_"+intLine+"\" VALUE=\"\"></center>";
//*** Column 5 ***//
//newCell = newRow.insertCell(4);
//newCell.id = newCell.uniqueID;
// newCell.setAttribute("className", "css-name");
// newCell.innerHTML = "<center><SELECT NAME=\"Column5_"+intLine+"\" ID=\"Column5_"+intLine+"\"></SELECT></center>";
//*** Create Option ***//
CreateSelectOption("Column5_" + intLine)
document.frmMain.hdnMaxLine.value = intLine;
}
function RemoveRow() {
intLine = parseInt(document.frmMain.hdnMaxLine.value);
if(parseInt(intLine) > 0) {
theTable = document.getElementById("tbExp");
theTableBody = theTable.tBodies[0];
theTableBody.deleteRow(intLine);
intLine--;
document.frmMain.hdnMaxLine.value = intLine;
}
}
CreateEfforts移行
設定ファイル
class CreateEfforts < ActiveRecord::Migration
def self.up
create_table :efforts do |t|
t.integer :project_task_id
t.integer :user_id
t.date :week_commencing
t.float :hours
t.timestamps
end
end
def self.down
drop_table :efforts
end
end