Store the answer to a question

M

Mark1234567

I want to ask a visitor the reason they visited our website using
Javascript:

Var strReason = Prompt("Why did you visit?")

How can I store this in a text file or Access database?

TIA
Mark
 
E

Erwin Moller

Mark1234567 said:
I want to ask a visitor the reason they visited our website using
Javascript:

Var strReason = Prompt("Why did you visit?")

How can I store this in a text file or Access database?

Hi,

How? By posting the answer to your server, and handle it from there.
JavaScript can, at most, help you post it, but it cannot store in in a
database, or flat file.

You need to use a serversidelanguage for that, like PHP.
(Actually, JavaScript can also be used serverside, but that is rare.)

Regards,
Erwin Moller
 
B

Bart Van der Donck

Mark1234567 said:
I want to ask a visitor the reason they visited our website using
Javascript:

Var strReason = Prompt("Why did you visit?")

How can I store this in a text file or Access database?

In 99.x% of the cases, you have three options:

- You can store it in a file at server;
- You can store it in a database at server (e.g. Access);
- You can store it in a cookie at client.

Hope this helps,
 
M

Mark1234567

Do you know what the Javascript code would be to store it in a flat
file on our server?
 
B

Bart Van der Donck

Do you know what the Javascript code would be to store it in a flat
file on our server?

It is not possible to perform such a task in client-side javascript.
You need a server-side language for that (PHP, ASP, ...).
 
E

Evertjan.

Mark1234567 wrote on 01 feb 2008 in comp.lang.javascript:

Perhaps it is rare to you Erwin, but not to the cyberworld.

[Please do not toppost on usenet]
Do you have any Javascript code that would do this?

You can user scripting.filesystemobject for that.

This is for appending text, I think [not tested]:

var theFile = server.mapPath('myFile.txt');
var fso = new ActiveXObject('Scripting.FileSystemObject');
var o = fso_OpenTextFile(theFile, 8, true,0);
o.write(sText);
o.close();
 
H

Hal Rosser

Do you know what the Javascript code would be to store it in a flat
file on our server?

Is your server MS IIS? If so, then ASP with Javascript is apparently what
you're insisting on using.
Is your page an 'ASP' - or HTML page?
In other words, What is the existing condition?
 
S

Steve Swift

Bart said:
In 99.x% of the cases, you have three options:

- You can store it in a file at server;
- You can store it in a database at server (e.g. Access);
- You can store it in a cookie at client.

Just so, but if you choose cookies, then 10% of the time it doesn't work
because the user of your site has blocked cookies. I made up the value
10%. Substitute your own, if you know better.
Whenever using cookies, your frame of mind has to be "nice if it works;
no harm if it doesn't".

You surely knew this, but the OP might not have.
 
T

Thomas 'PointedEars' Lahn

I have posted an example here a few days ago. Please search before you
post, see http://jibbering.com/faq/
It is not possible to perform such a task in client-side javascript.
You need a server-side language for that (PHP, ASP, ...).

Neither are ECMAScript implementations like JavaScript only client-side
programming languages, nor is PHP only a server-side programming language.

ASP (.NET) is not a programming language, it is a server-side application
framework (usually built on IIS). It can be used with (server-side) JScript
(.NET), among other programming languages.

As both JScript and JavaScript are ECMAScript implementations, they are very
similar. One could say that JScript, also used client-side in MSHTML e.g.
IE, is Microsoft's JavaScript, and simply answer "yes" to the OP's
uninformed question.


PointedEars
 
E

Erwin Moller

Evertjan. wrote:

Perhaps it is rare to you Erwin, but not to the cyberworld.

It is rare Evertjan, compared to languages like PHP, VB/ASP, Perl, Java,
etc..
I think you know that very well. :)
I do not have statistics at hand, but I actually never saw a server
running javascript serverside. And yes, I saw a lot.

Futhermore: I think I concluded correctly the OP isn't a very
experienced webprogrammer (otherwise he wouldn't ask that question).

In my opinion it is better in such cases to give a general correct
answer or direction (in this case: explaining the basic differences
between serverside and clientside processing), and not a rare solution
as serverside JavaScript.
Of course you are totally entitled to your own opinion, but I wonder how
helpfull that approach will be for the OP.

Regards,
Erwin Moller
 
E

Evertjan.

Erwin Moller wrote on 04 feb 2008 in comp.lang.javascript:
Evertjan. wrote:



It is rare Evertjan, compared to languages like PHP, VB/ASP, Perl,
Java, etc..
I think you know that very well. :)
I do not have statistics at hand, but I actually never saw a server
running javascript serverside. And yes, I saw a lot.

Futhermore: I think I concluded correctly the OP isn't a very
experienced webprogrammer (otherwise he wouldn't ask that question).

In my opinion it is better in such cases to give a general correct
answer or direction (in this case: explaining the basic differences
between serverside and clientside processing), and not a rare solution
as serverside JavaScript.
Of course you are totally entitled to your own opinion, but I wonder
how helpfull that approach will be for the OP.

I don't think it will help the op by stating it is rare.

It is like telling someone to pick his nose with a right hand's vinger
[VBS], because 80% of the human race does it with those fingers. If tha
someone is lefthanded [JS experienced and loving] it is perfectly
natural to do it [serverside JS] with her left hand. The fact that mor
often those fingers are used by programmers to scratch behind the right
ear [PHP, Perl, Java] is neither here nor there, as only the action of
the nose [ASP] should be taken into the statistical account.

IF ONE IS
experienced in javascript
AND
happens to use ASP serverside
AND
is not homesick to prehistoric BASIC programming in a new coat
IT IS
perfectly logical to use javascript serverside
IMHO.
 
V

VK

Neither are ECMAScript implementations like JavaScript only client-side
programming languages, nor is PHP only a server-side programming language.

ASP (.NET) is not a programming language, it is a server-side application
framework (usually built on IIS). It can be used with (server-side) JScript
(.NET), among other programming languages.

As both JScript and JavaScript are ECMAScript implementations, they are very
similar.

That makes me wondering again if you ever wrote a single line of code
in JScript.NET for ASP

JScript.NET (JScript 7.0 and 8.0 by Microsoft numbering schema) is
class-based strictly typed compiled language. It has interfaces,
import directives etc. Comparing client-side JScript for IE6/7 and
JScript.NET one find JScript.NET much closer to Java and C#.
JScript and JScript.NET are _very_ different languages despite thay
are sharing common grounds. To not going too far: last week a chunk of
ASP in JScript.NET was posted here with a question and no one of
regulars seems even recognized any "ECMAScript relations" of the code.
So saying "server-side or client-side JScript, still ECMAScript" is
the same nonsense as saying "Sinclair BASIC, QBASIC or Visual Basic -
simply say BASIC".
One could say that JScript, also used client-side in MSHTML e.g.
IE, is Microsoft's JavaScript, and simply answer "yes" to the OP's
uninformed question.

No, informed respondent would never say something stupid as that for
the reasons I explained above.
An informed but busy reader would just skip on answering as the
question is not related with Javascript.
An informed and bored reader would maybe take time to explain that the
server-side data storage is done by server-side programs and client-
side Javascript has no relation with them. All one need to do is to
provide a form to submit on the page like an option list of "How did
you find us?" and install some server-side form data prosessing
script. I assume it is IIS in OP's case because of mentioning Access;
but there is a great number of all kind of free form processing
programs for all environment, say:

ASP
http://www.scriptsearch.com/ASP/Scripts_and_Components/Survey_and_Voting/

PHP
http://www.scriptsearch.com/PHP/Scripts_and_Programs/Survey_and_Voting/

Perl
http://www.scriptsearch.com/Perl/Scripts_and_Programs/Polls_and_Voting/
 
T

Thomas 'PointedEars' Lahn

VK said:
Neither are ECMAScript implementations like JavaScript only client-side
programming languages, nor is PHP only a server-side programming language.

ASP (.NET) is not a programming language, it is a server-side application
framework (usually built on IIS). It can be used with (server-side) JScript
(.NET), among other programming languages.

As both JScript and JavaScript are ECMAScript implementations, they are very
similar.

That makes me wondering again if you ever wrote a single line of code
in JScript.NET for ASP

JScript.NET (JScript 7.0 and 8.0 by Microsoft numbering schema) is
class-based strictly typed compiled language. [...]

It isn't strictly-typed per se. It supports class-based inheritance and a
number of features that were included in Netscape's latest proposal for
ECMAScript Ed. 4, too, including strict typing. As for compilation, all
JScript code is (JIT-)compiled, as is all JavaScript code.

There is nothing in your "explanation" that proves me wrong. No doubt you
use your own definition of similarity. Besides, I have referred to both ASP
and ASP .NET, and you have ignored that there is indeed JavaScript 2.0 which
implements several features of Netscape's ECMAScript Ed. 4 proposal,
although there is only a test implementation available (Epimetheus).


PointedEars
 
V

VK

There is nothing in your "explanation" that proves me wrong. No doubt you
use your own definition of similarity. Besides, I have referred to both ASP
and ASP .NET, and you have ignored that there is indeed JavaScript 2.0 which
implements several features of Netscape's ECMAScript Ed. 4 proposal,
although there is only a test implementation available (Epimetheus).

Epimetheus? It is gone 9 years ago after a few weeks of beta testing.
Maybe it's time to forget?

Note:
to not get lost in all these "...script":
JavaScript - refers to the client-side language used in Gecko
browsers.
JScript - refers to the language trademark reserved by Microsoft
Javascript - (small "s") refers to all set of _actual_ implementations
provided by current browsers as opposed to:
ECMAScript - that refers to language specifications issued by ECMA
International

Now:

Microsoft has developed JScript 7.0 (market name JScript.NET) as the
next step in ECMAScript evolution: class-based inheritance, strict
typing, encapsulation, import directives, interfaces, manual memory
management and all other regular toys no one C++'er can possibly
imaging his life without. They left a generous gap in version
numbering - with IE6 using JScript 5.6, and then JScript 7.0 right
away - in order to be able to release new client-side versions with
versions below 7: because in the wildest nightmare no one in Microsoft
management would assume such power as JScript.NET to be available for
client-side scripting. Web applications are getting real challenge to
Microsoft Office products even with the current language limitations,
so the main task of the management was and remains to keep client-side
scripting capabilities as weak as possible as long as doable.
This way JScript < 7.0 was never used server-side, and JScript >= 7.0
was never use client side. With the profound structural and functional
differences between client-side JScript <= 5.6 and JScript.NET (>=
7.0) referring to them as some overall similar things is completely
misleading. I personally never used the term "JScript" in reference to
both, you may scan my posts.
See also http://msdn2.microsoft.com/en-us/library/e2h4yzx6.aspx

The other rivals did not contribute great into Javascript development
so the things were in deep stagnation for five years at least. Some
players spent these whole five years to make a descent script engine
and another 1.5 year to finally bring it in accordance with the year
1999 specs, so 6.5 - 7 years to produce a usable script engine. And by
"bring it in accordance" I don't mean to follow each and every dot and
comma in specs, I mean simply implement specified methods with more-or-
less specified results. No names, just to remind in what deep sh**
thing were.

It is not true that everything stopped completely. At the beginning of
this century Waldemar Horwat, who originally was in Netscape
Corporation and latter in Mozilla Foundation, started making drafts of
JavaScript 2.0, very similar by structure and capabilities to
Microsoft JScript.NET but intended right away for client-side as well
as for server-side deployment. Netscape and inheritedly Mozilla
Foundation are using their own version numbering, so with the version
number in use at that time 1.5 they also left a gap for intermediary
updates.
The project page URL long time linked in c.l.j. FAQ is still available
via WayBack Machine:
http://web.archive.org/web/20070713161258/http://www.mozilla.org/js/language/js20/
Unfortunately Waldemar Horwat left Mozilla Foundation at Summer of
2003 for his new position in Google, Inc. and ever since and for a few
years the project was completely abandoned.
The other rivals were completely silent all these years as I said,
struggling to implement even as little as it was spelled in old
ECMAScript 3rd. ed. The only exception was Macromedia/Adobe
ActionScript on Tamarin engine (Flash files) that had to develop in a
highly competitive environment all these years.

The recent - last 1.5 year - development is that first Brendan Eich
really started with "ECMAScript Edition 4", which is as I understand
the new project name instead of former "JavaScript 2.0". The project
page is at
http://www.ecmascript.org/

So by the end of 2007 we had Brendan Eich in Mozilla Foundation,
Waldemar Horwat in Google, Douglas Crockford in Yahoo! and the
appointed project manager in Microsoft (after Eric Lippert went out of
the deal the relevant department is short on widely recognizable
names, or maybe I'm just getting out of current bios). It resulted in
three camps over the battle for Javascript future:
1) "Refolution now!" represented by Mozilla Foundation
2) "As much as we can squeeze out of M$" represented by Google and
Yahoo!
3) "Get you lost all together and let us sell our Office" represented
by Microsoft

While positions 2) and 3) had some grounds for negotiations, 1) did
not go at all for 3) and all this resulted in 4th edition working
group collapse in November 2007, emotionally and rather picturally
described by Brendan Eich in his blog:
http://weblogs.mozillazine.org/roadmap/

The overall future of Javascript is rather cloudy now, especially with
possible changes in the camp 2) with Yahoo! currently considering the
acquisition proposal from Microsoft
http://yhoo.client.shareholder.com/press/releasedetail.cfm?ReleaseID=291270

If the deal is cut (and it is well possible with the ongoing Yahoo!
troubles), one of first thing to be put on cold would be Yahoo!'s
Javascript modules for rich client-side applications. That leaves
Google alone in the camp 2)
Lucky the company is powerful enough to still negotiate out some
common improvement steps for client-side scripting: plus of course and
as always the end-users pressure.

In this situation I just hope that Brendan Eich (== Mozilla Foundation
JavaScript) will not attempt to go by brute force way so implementing
JavaScript 2.0 / ECMAScript 4th / whatever on Gecko alone plus making
it the default mode engine. The conditions are just not here yet IMO
for such actions. Whatever is not supported by IE6/7 is useless for
WWW developers - so one needs to negotiate however upsetting it would
be.
 
V

VK

acquisition proposal from Microsoft
If you can't beat them, buy them out :)

Yeah, I'm getting tired to go away to the West... Strange people with
thunder sticks are still coming sooner or later to the land... :)

First I dropped Hotmail, now my ol'good Yahoo! Mail, now what? over
the mountains to GMail? :)

They did not say "yes" though.
 
T

Thomas 'PointedEars' Lahn

VK said:
Epimetheus? It is gone 9 years ago after a few weeks of beta testing.
Maybe it's time to forget?

Unsurprisingly, you missed the point.
Note:
to not get lost in all these "...script":
JavaScript - refers to the client-side language used in Gecko
browsers.

I daresay no programming language is restricted to client-side application;
that certainly includes JavaScript or ECMAScript implementations in general.
JavaScript is Netscape's/Mozilla.org's ECMAScript implementation. And
JFTR: While the statement about Gecko-based browsers is correct, the reverse
is not true. JavaScript does not require a user agent that uses the Gecko
layout engine.
JScript - refers to the language trademark reserved by Microsoft

As stated in the FAQ, JScript is Microsoft's implementation of ECMAScript.
JScript .NET is a commercial buzzword for JScript 7.0 (and above) which
requires the .NET framework.
Javascript - (small "s") refers to all set of _actual_ implementations
provided by current browsers as opposed to:

"Javascript" exists only in your imagination.
ECMAScript - that refers to language specifications issued by ECMA
International

The organization is called Ecma International since a while. That is to
emphasize it has abandoned its previous restriction to the European computer
manufacturers as its members and operation. That aside, the statement is
correct.
[VK's latest goodnight fairytale]


PointedEars
 
J

Jonathan

In the end that's what I did (sort of) by opening another window with a
querystring in it and using aspx to connect to a database to save the
querystring result.

I know a lot of people won't like what I did with www.orbisoft.com now --
when a new visitor leaves it asks them why...(only once). It has actually
been helpful to date. It only pops up once then an indefinite cookie stops
the JavaScript prompt from appearing again.

Thanks for the help.


Wow, nice longggg answer to the poor guy.
Mark, why not just use a form field and save the response?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,373
Latest member
Desiree036

Latest Threads

Top