R
Roy Adams
Hi forum
I have three text fields set up on a page that when submitted I want
them to be inserted in to a table but in differnt records at once.
the code below only seems to insert the last field
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<%
var colorForm = String(Request.Form("color"));
colorForm_array = colorForm.split(",");
if( colorForm != "" ){
//make the sql connection object and open it here
conn = Server.CreateObject('ADODB.Command');
conn.ActiveConnection = "dsn=Mydsn;";
for( i=0 ; i < colorForm_array.length ; i ++){
conn.CommandText = ("insert into color (color) values ('" +
colorForm_array + "')" );
}
conn.Execute();
conn.ActiveConnection.Close();
}
%>
all there is in the form are 3 text fields with the same name "color"
and a submit button
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<form name="form1" action="" method="post">
<table width="600" border="0" align="center" cellpadding="4"
cellspacing="2">
<tr>
<td width="300"> </td>
<td width="278"> </td>
</tr>
<tr>
<td> </td>
<td><input name="color" type="text" id="color"></td>
</tr>
<tr>
<td> </td>
<td><input name="color" type="text" id="color"></td>
</tr>
<tr>
<td> </td>
<td><input name="color" type="text" id="color"></td>
</tr>
<tr>
<td colspan="2"> <div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>
</form>
</body>
</html>
I'm quite new to this so any help is appriciated!
Thanks
I have three text fields set up on a page that when submitted I want
them to be inserted in to a table but in differnt records at once.
the code below only seems to insert the last field
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<%
var colorForm = String(Request.Form("color"));
colorForm_array = colorForm.split(",");
if( colorForm != "" ){
//make the sql connection object and open it here
conn = Server.CreateObject('ADODB.Command');
conn.ActiveConnection = "dsn=Mydsn;";
for( i=0 ; i < colorForm_array.length ; i ++){
conn.CommandText = ("insert into color (color) values ('" +
colorForm_array + "')" );
}
conn.Execute();
conn.ActiveConnection.Close();
}
%>
all there is in the form are 3 text fields with the same name "color"
and a submit button
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<form name="form1" action="" method="post">
<table width="600" border="0" align="center" cellpadding="4"
cellspacing="2">
<tr>
<td width="300"> </td>
<td width="278"> </td>
</tr>
<tr>
<td> </td>
<td><input name="color" type="text" id="color"></td>
</tr>
<tr>
<td> </td>
<td><input name="color" type="text" id="color"></td>
</tr>
<tr>
<td> </td>
<td><input name="color" type="text" id="color"></td>
</tr>
<tr>
<td colspan="2"> <div align="center">
<input type="submit" name="Submit" value="Submit">
</div></td>
</tr>
</table>
</form>
</body>
</html>
I'm quite new to this so any help is appriciated!
Thanks