Hi,
I am doing the add row table by calling the javascript function in asp.net.
The add row table is successfully created, but the problem is that i want to save the data in the columns and rows which have been added by the user. The problem is how am I going to get the value from javascript to insert into the db? Below are part of my code:
<table id="table1" width="95%" align="center" bgcolor="#E0FFFF" border=1>
<Form action="Bussiness.aspx?step=2" name="MillLicense" method="post">
<tr>
<td align="center" valign="top">Type of business</td>
<td align="center" valign="top">License No.</td>
<td align="center" valign="top">Remarks</td>
</tr>
<script language=JavaScript>
var arr_id = new Array();
total = 0;
</script>
<%
Dim cmd3 As OdbcCommand = New OdbcCommand("SELECT * FROM business", con)
con.Open()
Dim rsrecord3 As OdbcDataReader = cmd3.ExecuteReader()
If Not rsrecord3.Read() Then
Dim nobusiness As Boolean = True
End If
Dim total As Integer = 1
While rsrecord3.Read()
%>
<script language=JavaScript>
arr_id[total] = '<%=Trim(rsrecord3("id"))%>';
total++;
</script>
<%
total = total + 1
End While
con.Close()
%>
<input type="hidden" id="total1" value="1">
<input type="hidden" name="totalbus" id="totalbus" value="<%=total - 1%>">
</table>
<input type="button" value="Add Activity" onClick="addRow();">
<input type="submit" align="center" value=" Submit ">
<input type="reset" name="Reset" value="Reset" class="button">
</form>
</table>
///////////////////////////////////////////////////
function addRow()
{
var tbl = document.getElementById('table1');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var row = tbl.insertRow(lastRow);
// Type of bussiness
var i = 0
var Bus = row.insertCell(0);
var Business = document.createElement('select');
Business.name = 'BusinessType' + iteration;
<%
While rsrecord.read()
%>
Activity.options = new Option('<%=Trim(rsrecord("Business"))%>', '<%=Trim(rsrecord("Code"))%>');
i++;
<%
End While
con.Close()
%>
Bus.appendChild(Business);
// Licence No
var Licence = row.insertCell(1);
var LicenceNo = document.createElement('input');
LicenceNo.type = 'text';
LicenceNo.name = 'Licence' + iteration;
LicenceNo.id = 'Licence' + iteration;
LicenceNo.size = 7;
Licence.appendChild(LicenceNo);
// Remarks
var Comment = row.insertCell(2);
var Remarks = document.createElement('input');
Remarks.type = 'text';
Remarks.name = 'Remarks' + iteration;
Remarks.id = 'Remarks' + iteration;
Remarks.size = 7;
Comment.appendChild(Remarks);
****** This is the part that should save into the db, but i have totally no idea how to do it..
If Request.QueryString("step") = 2 Then
End If
Can somebody pls help.. it is quite urgent.. Thanks in advance.
I am doing the add row table by calling the javascript function in asp.net.
The add row table is successfully created, but the problem is that i want to save the data in the columns and rows which have been added by the user. The problem is how am I going to get the value from javascript to insert into the db? Below are part of my code:
<table id="table1" width="95%" align="center" bgcolor="#E0FFFF" border=1>
<Form action="Bussiness.aspx?step=2" name="MillLicense" method="post">
<tr>
<td align="center" valign="top">Type of business</td>
<td align="center" valign="top">License No.</td>
<td align="center" valign="top">Remarks</td>
</tr>
<script language=JavaScript>
var arr_id = new Array();
total = 0;
</script>
<%
Dim cmd3 As OdbcCommand = New OdbcCommand("SELECT * FROM business", con)
con.Open()
Dim rsrecord3 As OdbcDataReader = cmd3.ExecuteReader()
If Not rsrecord3.Read() Then
Dim nobusiness As Boolean = True
End If
Dim total As Integer = 1
While rsrecord3.Read()
%>
<script language=JavaScript>
arr_id[total] = '<%=Trim(rsrecord3("id"))%>';
total++;
</script>
<%
total = total + 1
End While
con.Close()
%>
<input type="hidden" id="total1" value="1">
<input type="hidden" name="totalbus" id="totalbus" value="<%=total - 1%>">
</table>
<input type="button" value="Add Activity" onClick="addRow();">
<input type="submit" align="center" value=" Submit ">
<input type="reset" name="Reset" value="Reset" class="button">
</form>
</table>
///////////////////////////////////////////////////
function addRow()
{
var tbl = document.getElementById('table1');
var lastRow = tbl.rows.length;
// if there's no header row in the table, then iteration = lastRow + 1
var row = tbl.insertRow(lastRow);
// Type of bussiness
var i = 0
var Bus = row.insertCell(0);
var Business = document.createElement('select');
Business.name = 'BusinessType' + iteration;
<%
While rsrecord.read()
%>
Activity.options = new Option('<%=Trim(rsrecord("Business"))%>', '<%=Trim(rsrecord("Code"))%>');
i++;
<%
End While
con.Close()
%>
Bus.appendChild(Business);
// Licence No
var Licence = row.insertCell(1);
var LicenceNo = document.createElement('input');
LicenceNo.type = 'text';
LicenceNo.name = 'Licence' + iteration;
LicenceNo.id = 'Licence' + iteration;
LicenceNo.size = 7;
Licence.appendChild(LicenceNo);
// Remarks
var Comment = row.insertCell(2);
var Remarks = document.createElement('input');
Remarks.type = 'text';
Remarks.name = 'Remarks' + iteration;
Remarks.id = 'Remarks' + iteration;
Remarks.size = 7;
Comment.appendChild(Remarks);
****** This is the part that should save into the db, but i have totally no idea how to do it..
If Request.QueryString("step") = 2 Then
End If
Can somebody pls help.. it is quite urgent.. Thanks in advance.