Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the value from javascript to insert to mysql

Status
Not open for further replies.

Mentos123

Programmer
Feb 8, 2007
9
MY
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.
 

Please read faq222-2244 where you will learn forum etiquette. Cross posting is discouraged - posting in the wrong forum is counter-productive. This is the Classic ASP forum so please keep ASP.NET posts in forum855.

I notice that you have already been advised of this - and ignored the advice (thread333-1353480)

___________________________________________________________
If you want the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
Steam Engine Prints
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top