472,983 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Vocabulary Practice Application - Forms, Arrays, Cookies?

Trying to get some ideas on a simple javascript project (to teach myself the

I want to develop a client-side vocabulary practice application that would
allow users to
enter their own words, their own definitions plus an example of how the word
used in practice. It'll be all client side with - cookies? to get
persistence so that the words won't
disappear on me each time the page is closed (which is what happened when I
just arrays with no cookies. .So, you can imagine (maybe) setting up 3
arrays as follows:

var word = new Array( );
var definition = new Array( );
var example = new Array( );

Then, using functions like:

addWord(); (or, newWord( ) )
addDefinition( );
addExample( );
nextWord( );
previousWord( );

In the HTML I want 3 input fields of some kind plus 3 buttons: "Previous
Word", "Next Word",
"New Word".

I was able to do this using arrays and hard-coding each new word, definition
and word-usage-example,into the
source, but then I thought of allowing the user to enter his/her own words,
definitions, examples.
This is where I started thinking of state maintenance and cookies. I'm
thinking of allowing input of,
say, 1,000 words at most.

Just wondering if cookies are the right way to go.
Jul 20 '05 #1
2 3013
by closed did you mean _unloaded_ (going to another page, that is) or
downright the window which gets closed? if your concern is to make a data
persistent troughout more pages unloaded, arrange your internal links so
that they carry a query: the subsequent page can via js analyze it and make
<a href="www.foo.html?myword=cool">
of course, you can give an id or a name to that anchor and append the query
accordingly to other actions occurred in the current page scripts.

yet, if what you meant is to store on the user's machine (client) a cookie
which keeps within a whole dictionary, no way: cookies are meant to store
limited amount of data. I could check a manual to be more precise, I can't
remember the amount here, but you can store at most, probably, 10 words -
and you do NOT have unlimited capabilities to store cookies on a machine
(you can imagine what a hacker could do if that would be possible, he could
saturate your disk by simply storing cookies whose text is the whole page
and making repeatedly copies of it by a loop. This I hope makes you
understand _why_ cookis have to be limited in their scopes).

of course, you could ask an user to donwload a js file - but here you're
already well beyond the ability of the average user: he/she could download
the js and save it in a path he/she prefers. Then, upon loading your page
he/she should type the path of the js on his/her machine in a form: you
append such path to a query so you save it throughout the session (or you
could save such typed path to a cookies, this yes would be possible) and
then you can dynamically write a script src=that path into every subsequent
file he/she visitis within the "application" - this if you want to keep it
_client_ side, which is hihgly unadvisable for this type of applications.
Yet, maybe you just like the challenge who knows (I'm a guy who likes
javascript challenges just beacuse, for instance lol), and yet you have to
concur: the average user can be unable to save a js and then remember where
it is and then type the path to it.

Last but not least, this would work if I do it on my machine, but I never
tried it online so I don't know if any security trick would prevent an
online machine from retreiving local files EVEN if they are js and their
paths typed in by the user.

Anyway, I hope you can find hints or ideas - my suggestion doesn't mean more
and, as I said, that should actually be made server side, that's the correct
approach. Unless, as I said, you just relish the challenge :-)
Alberto vallini
"Citoyen du Monde" <br************@hotmail.com>
persistence so that the words won't
disappear on me each time the page is closed (which is what happened when

Jul 20 '05 #2
Thanks for responding to this Alberto. You've got some good ideas in here
I will definitely look into.

I'm now looking at the following link entitled "Persisting Form Data":


By 'closed' I meant shutting down IE6 completely, or even shutting down the
computer and
rebooting, then coming back, say, five years later, to find all my
vocabulary words/definitions/examples still intact.

I think you're right about cookies - probably not the most elegant solution.

I've recklessly cut and paste a bit of the above link (page) below.

Persisting Form Data Internet Development Index


Using HTML to design forms comes with some drawbacks, namely the need for a
server or client-side script to process the form data. The saveSnapshot
behavior can be used to save a Web page and persist the form data directly
within the page itself. This allows a larger audience to use Web forms for
day-to-day activities without needing a special script to process and
deliver the information.

An expense report can be created with HTML, persisted with the saveSnapshot
behavior, and then sent in e-mail to an employee or employer with no
specialized scripting.

Essential Persistence Preparations
The saveSnapshot behavior requires certain elements in order to function: a
meta element, a style block, an ID attribute, and a CLASS attribute on the
object to persist.

Security Alert Using this behavior incorrectly can compromise the security
of your application. This behavior persists data as plain text in a saved
Web page. Text is not encrypted and therefore not secure. Any application
that has access to the drive where the page is saved also has access to the
data and can tamper with it. Therefore, it is recommended that you not
persist sensitive data like credit card numbers. For more information, see
Security Considerations: DHTML and Default Behaviors.
The META Tag and STYLE Block
The meta and style elements are used to inform the browser that the Web page
is persistent.

<META NAME="save" CONTENT="snapshot">
.saveSnapshot {behavior:url(#default#savesnapshot);}
</STYLE>The CLASS Attribute
The CLASS attribute identifies the type of persistence the element is using.

<ELEMENT CLASS=saveSnapshot ID=oPersistElement.. >The STYLE Attribute Set
The style can also be set inline with the element.

Defining a Form to Persist

Persisting form data using the saveSnapshot behavior does not require
additional scripting. Therefore, the entire form will appear almost like any
other form except for the required CLASS and ID attributes. These attributes
may either be placed on the form object, or on the individual form elements.

Persisting the Entire Form
The following form only needs a defined CLASS in order to persist.

<FORM ID=oPersistForm CLASS=saveSnapshot>
First Name: <INPUT TYPE=text>
Last Name: <INPUT TYPE=text>
Exemptions: <INPUT TYPE=text>
</FORM>By giving the form object an ID and a CLASS of saveSnapshot, the
entire form will persist. If persisting only selected elements is desired,
then the ID and CLASS attributes can be moved from the form object onto
those elements.

In the following example, the First Name and Last Name text fields are
persisted, but the Exemptions field is not. The entire Web page for this
form would include the HTML form, the essential persistence information, and
html, head and body elements.

First Name: <INPUT TYPE=text ID=oPersistInput1 CLASS=saveSnapshot>
Last Name: <INPUT TYPE=text ID=oPersistInput2 CLASS=saveSnapshot>
Exemptions: <INPUT TYPE=text>
</FORM>In the next example, a complete HTML file is shown where all text
fields are persisted.

Show Example

<META NAME="save" CONTENT="snapshot">
.saveSnapshot {behavior:url(#default#savesnapshot);}
<FORM ID=oPersistForm CLASS=saveSnapshot>
First Name: <INPUT TYPE=text>
Last Name: <INPUT TYPE=text>
Exemptions: <INPUT TYPE=text>

Jul 20 '05 #3

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

Similar topics

by: David | last post by:
Hello. I am looking for advice on what is "best practice" regarding looping through a form to check its checkboxes and associated data fields. Here is what I am trying to do (Here is the page...
by: Sivashankaran Vaidhyalingam | last post by:
Hi folks, I have an aspx application App A hosted in a server which is inside the intranet . I need to serve pages from this application _through_ another application App B which acts as a proxy...
by: mark | last post by:
Can't figure this one out. I appears to not be code related. After surfing my asp.net web app for a while 5 - 10 min. it fails to open any further connections to my access 2000 database. There...
by: tommy | last post by:
hello everbody, i write a little asp-application with forms-authentication. i copy my aspx-files with web.config to my webspace and i get the error above... i tried to set the...
by: Sean | last post by:
HI There, I am having trouble deploying my .aspx pages to a remote server, I have made changes to the config file and it still returns an error. I have also contacted the server administrator to...
by: Trevor Andrew | last post by:
Hi There, Hopefully this isn't too difficult a question to express here. I have a 3 tier application. 1. Presentation Tier: ASP.NET web application. 2. Middle Tier: ASP.NET Web Services that...
by: Marc Gravell | last post by:
Kind of an open question on best-practice for smart-client design. I'd really appreciate anyones views (preferably with reasoning, but I'll take what I get...). Or if anybody has any useful links...
by: Sathyaish | last post by:
Thingies: - Report Definition Language (RDL) - Resource Definition Framework (RDF) - Web Service Definition Language (WSDL) - C# Application Markup Language (CSAML) - Extensible Application...
by: Anup Daware | last post by:
Hi All, I am facing this very weird issue, for every server request my control is redirecting to the login page and again coming back to the actual page from where the request was initiated when I...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.