473,890 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="VB CRIPT" CODEPAGE="1252" %>
<!--#include virtual="/Connections/EmployeeStatusC hange.asp" -->
<%
// *** Edit Operations: declare variables

// set the form action variable
var MM_editAction = Request.ServerV ariables("SCRIP T_NAME");
if (Request.QueryS tring) {
MM_editAction += "?" + Server.HTMLEnco de(Request.Quer yString);
}

// 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_editConnecti on = MM_ITESC_STRING ;
var MM_editTable = "MacForm";
var MM_editRedirect Url = "SuggestionConf .htm";
var MM_fieldsStr =
"NewHire|value| Change|value|Tr ansfer|value|Tr ansferFrom|valu e|TransferTo|va lue|TypeOfEmplo yee|value|TempN umberOfDays|val ue|EmployeeName |value|Title|va lue|PayNumber|v alue|Department |value|StartDat e|value|EndDate |value|Managers Name|value|Mana gersPhone|value |Location|value |Telecommunicat ionDevice|value |PCType|value|M onitorType|valu e|PrinterType|v alue|ARNumber|v alue|PCSerialNu mber|value|Asse tTag|value|Wire lessNic|value|R ASVPN|value|BPC S|value|LogPro| value|Payroll|v alue|Additional SoftwareRequest s|value|Headset |value|HeadsetO ptions|value|Om itLongDistance| value|OmitInter nationalDialing |value|Building Access|value|Co mmentsNotes|val ue|RequestedBy| value|Date|valu e";
var MM_columnsStr =
"NewHire|none,1 ,0|Change|none, 1,0|Transfer|no ne,1,0|Transfer From|',none,''| TransferTo|',no ne,''|TypeOfEmp loyee|',none,'' |TempNumberOfDa ys|',none,''|Em ployeeName|',no ne,''|Title|',n one,''|PayNumbe r|',none,''|Dep artment|',none, ''|StartDate|', none,NULL|EndDa te|',none,NULL| ManagersName|', none,''|Manager sPhone|',none,' '|Location|',no ne,''|Telecommu nicationDevice| ',none,''|PCTyp e|',none,''|Mon itorType|',none ,''|PrinterType |',none,''|ARNu mber|',none,''| PCSerialNumber| ',none,''|Asset Tag|',none,''|W irelessNic|none ,none,NULL|RASV PN|none,none,NU LL|BPCS|none,1, 0|LogPro|none,1 ,0|Payroll|none ,1,0|Additional SoftwareRequest s|',none,''|Hea dset|none,1,0|H eadsetOptions|' ,none,''|OmitLo ngDistance|none ,1,0|OmitIntern ationalDialing| none,1,0|Buildi ngAccess|none,1 ,0|CommentsNote s|',none,''|Req uestedBy|',none ,''|Date|',none ,NULL";

// create the MM_fields and MM_columns arrays
var MM_fields = MM_fieldsStr.sp lit("|");
var MM_columns = MM_columnsStr.s plit("|");

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

// append the query string to the redirect URL
if (MM_editRedirec tUrl && Request.QuerySt ring &&
Request.QuerySt ring.Count > 0) {
MM_editRedirect Url += ((MM_editRedire ctUrl.indexOf(' ?') ==
-1)?"?":"&") + Request.QuerySt ring;
}
}
%>
<%
// *** 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.lengt h; 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.CreateOb ject('ADODB.Com mand');
MM_editCmd.Acti veConnection = MM_editConnecti on;
MM_editCmd.Comm andText = MM_editQuery;
MM_editCmd.Exec ute();
MM_editCmd.Acti veConnection.Cl ose();

if (MM_editRedirec tUrl) {
Response.Redire ct(MM_editRedir ectUrl);
}
}

}
%>

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

<body>
<form id="form1" name="form1" method="post"
action="<%=MM_e ditAction%>">
<p>
<label>Employ ee Name
<input name="EmployeeN ame" type="text" id="EmployeeNam e" />
</label>
</p>
<p>
<label>Pay Number
<input name="PayNumber " type="text" id="PayNumber" />
</label>
</p>
<p>
<label>Locati on
<input name="Location" type="text" id="Location" />
</label>
</p>
<p>
<label>Requeste d By
<input name="Requested By" 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
/ITEmployeeStatu sChangeForm.asp , line 7

var MM_editAction = Request.ServerV ariables("SCRIP T_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="VB SCRIPT" CODEPAGE="1252" %> To <%@LANGUAGE="JS CRIPT"
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........al l 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="VB SCRIPT"%>
<!--#include file="../Connections/ITESC.asp" -->
<%
' FileName="Conne ction_odbc_conn _dsn.htm"
' Type="ADO"
' DesigntimeType= "ADO"
' HTTP="false"
' Catalog=""
' Schema=""
Dim MM_ITESC_STRING
MM_ITESC_STRING = "dsn=EmployeeSt atusChange;"
%>

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 4233
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="Conne ction_odbc_conn _dsn.asp"
Type="ADO"
DesigntimeType= "ADO"
HTTP="false"
Catalog=""
Schema=""
Dim MM_ITESC_STRING
MM_ITESC_STRING = "dsn=EmployeeSt atusChange;"
'%>

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="JS CRIPT" CODEPAGE="1252" %>
<!--#include virtual="/Connections/ITESC.asp" -->
<%
// *** Edit Operations: declare variables

// set the form action variable
var MM_editAction = Request.ServerV ariables("SCRIP T_NAME");
if (Request.QueryS tring) {
MM_editAction += "?" + Server.HTMLEnco de(Request.Quer yString);
}

The line: if (Request.QueryS tring) {

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
6043
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
5992
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 javascript code and work out what it does but I can't really write it from scratch.
3
2250
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: (1) I want to count how many characters there is in a string. In ASP I just use <%=Len(Variabel)%> How do I do this in Jscript?
16
9386
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 times it returns VarType() is vbEmpty. This is driving me mad! Also, does anyone know what the properties and methods are for the object returned by GetRef()? TIA.
1
2011
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 work. Can anyone help <SCRIPT LANGUAGE ="VBSCRIPT" RUNAT="SERVER" Dim tes test = 10 </SCRIPT><SCRIPT LANGUAGE ="JSCRIPT" RUNAT="SERVER" Response.Write(test) </SCRIPT>
5
1481
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
5803
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 Pool. One site gives the 800a0006 error on a formatpercent, another site (on the same server) does not. Here's the kicker...the one site only fails if the number is LESS THAN 1.
13
1661
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 scheduled August auto-update for Windows XP and Windows Vista systems. The head of Microsoft Windows Scripting department reminds to complete the move to VBScript equivalents during the April-July transition period for all affected solutions.
1
3483
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
9815
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10802
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10908
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9618
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5835
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6035
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4259
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3267
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.