473,378 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Microsoft VBScript & JScript Help

Hello,

I have created a connection to my Access database with Dreamweaver and
made a simple form with 4 fields.

The code behind this form was/is:

<%@LANGUAGE="VBCRIPT" CODEPAGE="1252"%>
<!--#include virtual="/Connections/EmployeeStatusChange.asp" -->
<%
// *** Edit Operations: declare variables

// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
if (Request.QueryString) {
MM_editAction += "?" + Server.HTMLEncode(Request.QueryString);
}

// boolean to abort record edit
var MM_abortEdit = false;

// query string to execute
var MM_editQuery = "";
%>
<%
// *** Insert Record: set variables

if (String(Request("MM_insert")) == "form1") {

var MM_editConnection = MM_ITESC_STRING;
var MM_editTable = "MacForm";
var MM_editRedirectUrl = "SuggestionConf.htm";
var MM_fieldsStr =
"NewHire|value|Change|value|Transfer|value|Transfe rFrom|value|TransferTo|value|TypeOfEmployee|value| TempNumberOfDays|value|EmployeeName|value|Title|va lue|PayNumber|value|Department|value|StartDate|val ue|EndDate|value|ManagersName|value|ManagersPhone| value|Location|value|TelecommunicationDevice|value |PCType|value|MonitorType|value|PrinterType|value| ARNumber|value|PCSerialNumber|value|AssetTag|value |WirelessNic|value|RASVPN|value|BPCS|value|LogPro| value|Payroll|value|AdditionalSoftwareRequests|val ue|Headset|value|HeadsetOptions|value|OmitLongDist ance|value|OmitInternationalDialing|value|Building Access|value|CommentsNotes|value|RequestedBy|value |Date|value";
var MM_columnsStr =
"NewHire|none,1,0|Change|none,1,0|Transfer|none,1, 0|TransferFrom|',none,''|TransferTo|',none,''|Type OfEmployee|',none,''|TempNumberOfDays|',none,''|Em ployeeName|',none,''|Title|',none,''|PayNumber|',n one,''|Department|',none,''|StartDate|',none,NULL| EndDate|',none,NULL|ManagersName|',none,''|Manager sPhone|',none,''|Location|',none,''|Telecommunicat ionDevice|',none,''|PCType|',none,''|MonitorType|' ,none,''|PrinterType|',none,''|ARNumber|',none,''| PCSerialNumber|',none,''|AssetTag|',none,''|Wirele ssNic|none,none,NULL|RASVPN|none,none,NULL|BPCS|no ne,1,0|LogPro|none,1,0|Payroll|none,1,0|Additional SoftwareRequests|',none,''|Headset|none,1,0|Headse tOptions|',none,''|OmitLongDistance|none,1,0|OmitI nternationalDialing|none,1,0|BuildingAccess|none,1 ,0|CommentsNotes|',none,''|RequestedBy|',none,''|D ate|',none,NULL";

// create the MM_fields and MM_columns arrays
var MM_fields = MM_fieldsStr.split("|");
var MM_columns = MM_columnsStr.split("|");

// set the form values
for (var i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = String(Request.Form(MM_fields[i]));
}

// append the query string to the redirect URL
if (MM_editRedirectUrl && Request.QueryString &&
Request.QueryString.Count > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') ==
-1)?"?":"&") + Request.QueryString;
}
}
%>
<%
// *** Insert Record: construct a sql insert statement and execute it

if (String(Request("MM_insert")) != "undefined") {

// create the sql insert statement
var MM_tableValues = "", MM_dbValues = "";
for (var i=0; i+1 < MM_fields.length; i+=2) {
var formVal = MM_fields[i+1];
var MM_typesArray = MM_columns[i+1].split(",");
var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] :
"";
var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] :
"";
var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] :
"";
if (formVal == "" || formVal == "undefined") {
formVal = emptyVal;
} else {
if (altVal != "") {
formVal = altVal;
} else if (delim == "'") { // escape quotes
formVal = "'" + formVal.replace(/'/g,"''") + "'";
} else {
formVal = delim + formVal + delim;
}
}
MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i];
MM_dbValues += ((i != 0) ? "," : "") + formVal;
}
MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues
+ ") values (" + MM_dbValues + ")";

if (!MM_abortEdit) {
// execute the insert
var MM_editCmd = Server.CreateObject('ADODB.Command');
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();

if (MM_editRedirectUrl) {
Response.Redirect(MM_editRedirectUrl);
}
}

}
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="post"
action="<%=MM_editAction%>">
<p>
<label>Employee Name
<input name="EmployeeName" type="text" id="EmployeeName" />
</label>
</p>
<p>
<label>Pay Number
<input name="PayNumber" type="text" id="PayNumber" />
</label>
</p>
<p>
<label>Location
<input name="Location" type="text" id="Location" />
</label>
</p>
<p>
<label>Requested By
<input name="RequestedBy" type="text" id="RequestedBy" />
</label>
</p>
<p>
<label>
<input type="submit" name="Submit" value="Submit" />
</label>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>
</body>
</html>

__________________________________________________ ________________________

But when I go to "preview" this form in a browser I get the following
error:

Microsoft VBScript complilation error '800a0401'
Expected end of statement
/ITEmployeeStatusChangeForm.asp, line 7

var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
So I have figured out that the code must be written in JScript and NOT
VBScript b/c if I change the first line in the code from
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%> To <%@LANGUAGE="JSCRIPT"
CODEPAGE="1252"%> I can see my form!!!

I must be on to something but hold your horses and get ready for what
happens next:

If I fill in the 4 basic fields on this form and hit the submit button
then viola........all my information is submitted somewhere and to
someone in the WWW but it sure as hell is not going into my database.

Can someone perhaps see what is happening to this?? I have a
connections folder in my database which includes the "include" file of
information regarding the connction to the DSN. The code behind this
file is as follows:
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../Connections/ITESC.asp" -->
<%
' FileName="Connection_odbc_conn_dsn.htm"
' Type="ADO"
' DesigntimeType="ADO"
' HTTP="false"
' Catalog=""
' Schema=""
Dim MM_ITESC_STRING
MM_ITESC_STRING = "dsn=EmployeeStatusChange;"
%>

But I also notice if I leave codes as is then they are generating 2
scripts. The include is in VB and the form is in JS.

Well I thought this post could be a start and perhaps someone can see
what I can't and help me to figure this out!!! I find it hard to
believe that creating a form and submitting it to a database is this
difficult but I have been working on this for over 2 weeks now and
still have nothing to show for it but a huge folder of "how to do this
and that's" that haven't explained very much!!!

Any help is much appreciated.
Thanks,
Justine

Mar 9 '06 #1
1 4188
Well I still haven't figured anything out. But I did do a couple
changes and am now receiving the following error when I try to view my
form in a browser window:

Microsoft JScript compilation error '800a03ec'

Expected ';'

/Connections/ITESC.asp, line 8

Dim MM_ITESC_STRING
----^

The include file code is:
<%
FileName="Connection_odbc_conn_dsn.asp"
Type="ADO"
DesigntimeType="ADO"
HTTP="false"
Catalog=""
Schema=""
Dim MM_ITESC_STRING
MM_ITESC_STRING = "dsn=EmployeeStatusChange;"
'%>

So I am guessing by the error that it is talking about the code in my
include file b/c it points to the line: Dim MM_ITESC_STRING as line 8
and line 8 in my form is:
<%@LANGUAGE="JSCRIPT" CODEPAGE="1252"%>
<!--#include virtual="/Connections/ITESC.asp" -->
<%
// *** Edit Operations: declare variables

// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
if (Request.QueryString) {
MM_editAction += "?" + Server.HTMLEncode(Request.QueryString);
}

The line: if (Request.QueryString) {

Can anyone help me out here?
Thanks,
Justine

Mar 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

29
by: Christopher Brandsdal | last post by:
If I have a .ASP page that runs JScript code - is it possible to include an ..ASP page that runs VBscript???
20
by: Harag | last post by:
Hi All. I'm stating out doing some web developing. I was wondering which of the server side languages should I concentrate on and learn. I Know CSS, HTML, T-SQL I can look at the client...
3
by: Christopher Brandsdal | last post by:
Hi! Maby this is wring newsgroup.. I'm using ASP / VBscript on my own cms system, but I needed to use some jscript to make something work... I'm new to jscript, so here is a simple question:...
16
by: Mike Schinkel | last post by:
Does anyone know if there are bugs in VBScript's GetRef()? I'm using VBScript Version 5.6.8515 on Win2003Server w/ASP. Sometimes it returns an object that VarType() says is a vbObject. Other...
1
by: alaa | last post by:
I have the following code in an ASP page but it does not seem to allow a JScript to access VBScript variables. But if a VBScript accesses a variable in declared in a JScript TAG then it seems to...
5
by: Bruce W.1 | last post by:
Do most people use vbscript or jscript to control their ASP pages? I'm trying to decide which to learn. Thanks for your help.
7
by: dkiernan | last post by:
I am stumped. I have several websites running on a 2003 IIS6 box, all running basically the same code (each site has its own home directory and copy of the code). All are running in the same App...
13
by: VK | last post by:
04.01.07 Redmond, WA Today it was officially announced that Microsoft is planning to discontinue client-side JScript support effective 10.08.07 The engine will be blocked and removed on the...
1
by: Andrew Wan | last post by:
How can VBScript code access JScript code variables in the same ASP page? <SCRIPT LANGAUGE="VBScript"> Dim a a = 10 </SCRIPT> <SCRIPT LANGUAGE="JScript"> Response.Write(a); </SCRIPT>
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.