R
Roy
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="JAVASCRIPT" CODEPAGE="1252"%>
<%
var ProductID =1;
var colorForm = String(Request.QueryString("color"));//get the form
field and put into var
if(colorForm != "undefined" || colorForm != " " ){
var text = "" ;
colorForm = colorForm.replace(/'/g, "''");
colorForm_array = colorForm.split(",");//split at ","
for( i=0 ; i < colorForm_array.length ; i ++){// loop through the array
if (colorForm_array > " " ) {// if there is something in the array
conn = Server.CreateObject('ADODB.Command');//make the sql connection
object and open it here
conn.ActiveConnection = "dsn=Blenz;";
conn.CommandText = ("insert into color (color,ProductID) values ('" +
colorForm_array + "','" + ProductID + "')" ) //insert into table
field/s
conn.Execute();//do the job
conn.ActiveConnection.Close();//close
}
}
Response.Redirect("coloursOn.asp?ProductID=" +ProductID) ;
}
else
{
Response.Redirect("insert_done.asp?ProductID=" +ProductID)
}
%>
what's wrong with this!!?
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="JAVASCRIPT" CODEPAGE="1252"%>
<%
var ProductID =1;
var colorForm = String(Request.QueryString("color"));//get the form
field and put into var
if(colorForm != "undefined" || colorForm != " " ){
var text = "" ;
colorForm = colorForm.replace(/'/g, "''");
colorForm_array = colorForm.split(",");//split at ","
for( i=0 ; i < colorForm_array.length ; i ++){// loop through the array
if (colorForm_array > " " ) {// if there is something in the array
conn = Server.CreateObject('ADODB.Command');//make the sql connection
object and open it here
conn.ActiveConnection = "dsn=Blenz;";
conn.CommandText = ("insert into color (color,ProductID) values ('" +
colorForm_array + "','" + ProductID + "')" ) //insert into table
field/s
conn.Execute();//do the job
conn.ActiveConnection.Close();//close
}
}
Response.Redirect("coloursOn.asp?ProductID=" +ProductID) ;
}
else
{
Response.Redirect("insert_done.asp?ProductID=" +ProductID)
}
%>
what's wrong with this!!?