473,399 Members | 3,038 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,399 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
language).

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
is
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
used
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 3059
hi
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
deductions:
<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 :-)
ciao
Alberto vallini
http://www.unitedscripters.com/
"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

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

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

http://msdn.microsoft.com/library/de...thor/persisten
ce/overview.asp

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">
<STYLE>
.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
Inline
The style can also be set inline with the element.

<ELEMENT
CLASS="saveSnapshot"
STYLE="behavior:url(#default#savesnapshot)"
ID="oPersistElement"
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.

<FORM>
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

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


Jul 20 '05 #3

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

Similar topics

4
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...
0
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...
2
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...
4
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...
3
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...
4
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...
3
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...
3
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...
0
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.