Hello everyone
I'm doing a multiple insert from ten text fields.
all named color
when I submit the from with the text fields
it goes to an asp page with the script to do the job
and the go to another page, I've got that bit going but what if the user
leaves the fields empty an hits submit?
ok a simple enough thing of putting an else in the script, this isn't
working!! it always does the first thing
I've tried so many different variations.
it seems so simple but i just can't get it
here's the full script
<%@LANGUAGE="JA VASCRIPT" CODEPAGE="1252" %>
<%
var ProductID =1;
var colorForm = String(Request. QueryString("co lor"));//get the form
field and put into var
if(colorForm != "undefined" || colorForm != " " ){
var text = "" ;
colorForm = colorForm.repla ce(/'/g, "''");
colorForm_array = colorForm.split (",");//split at ","
for( i=0 ; i < colorForm_array .length ; i ++){// loop through the array
if (colorForm_arra y[i] > " " ) {// if there is something in the array
conn = Server.CreateOb ject('ADODB.Com mand');//make the sql connection
object and open it here
conn.ActiveConn ection = "dsn=Blenz; ";
conn.CommandTex t = ("insert into color (color,ProductI D) values ('" +
colorForm_array[i] + "','" + ProductID + "')" ) //insert into table
field/s
conn.Execute();//do the job
conn.ActiveConn ection.Close();//close
}
}
Response.Redire ct("coloursOn.a sp?ProductID=" +ProductID) ;
}
else
{
Response.Redire ct("insert_done .asp?ProductID= " +ProductID)
}