Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > parsing complex user inputs

Reply
Thread Tools

parsing complex user inputs

 
 
Sven Neuberg
Guest
Posts: n/a
 
      10-25-2004

Hi,

I have been handed the task of updating and maintaining a web
application, written in ASP and Javascript, that takes complex
user inputs in HTML form and submits them to server-side ASP
pages for processing. The problem is, the user inputs can
become very complex, and the way this application was developed,
the inputs are all concatenated into monstrously long strings
of text that are then submited as <hidden> inputs in HTML forms
and parsed by the server-side ASP. This results in hideous strings
that go on and on like
johnsmith~1232^01^Yes^no~~|43|april

etc. etc. This code is an incredible pain to maintain and update.
There has got to be a better way to do this. I am required to
use javascript and vbscript in ASP pages on the client side,
and ASP pages for processing data on the server side. I can't
switch to a different technology, or use .NET, or anything like
that. I have to use JS and VBScript to get intricate and lengthy
user inputs and submit them for processing. I would like to
store these inputs in objects somehow and then get the data
from those objects, if possible.

If anyone could suggest a better method for doing all of this
in javascript, even just to point me in the right direction, I would
greatly appreciate it.

sven



 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      10-25-2004
"Sven Neuberg" <> wrote in message
news:kHafd.6882$ ...
>
> Hi,
>
> I have been handed the task of updating and maintaining a web
> application, written in ASP and Javascript, that takes complex
> user inputs in HTML form and submits them to server-side ASP
> pages for processing. The problem is, the user inputs can
> become very complex, and the way this application was developed,
> the inputs are all concatenated into monstrously long strings
> of text that are then submited as <hidden> inputs in HTML forms
> and parsed by the server-side ASP. This results in hideous strings
> that go on and on like
> johnsmith~1232^01^Yes^no~~|43|april
>
> etc. etc. This code is an incredible pain to maintain and update.
> There has got to be a better way to do this. I am required to
> use javascript and vbscript in ASP pages on the client side,
> and ASP pages for processing data on the server side. I can't
> switch to a different technology, or use .NET, or anything like
> that. I have to use JS and VBScript to get intricate and lengthy
> user inputs and submit them for processing. I would like to
> store these inputs in objects somehow and then get the data
> from those objects, if possible.
>
> If anyone could suggest a better method for doing all of this
> in javascript, even just to point me in the right direction, I would
> greatly appreciate it.
>
> sven
>


It sounds like the user fills in numerous fields and, on form submission,
the data is concatenated into a single (hidden) field for passing to the
server where it is parsed (perhaps using "Split()"), validated, and
processed.

One option is remove the concatenation+parsing and just refer to each file
via "Request.Form("fieldname") on the server.

Is any validation done on the client-side?

Is any manipulation done on the client-side?



 
Reply With Quote
 
 
 
 
Grant Wagner
Guest
Posts: n/a
 
      10-25-2004
Sven Neuberg wrote:

> Hi,
>
> I have been handed the task of updating and maintaining a web
> application, written in ASP and Javascript, that takes complex
> user inputs in HTML form and submits them to server-side ASP
> pages for processing. The problem is, the user inputs can
> become very complex, and the way this application was developed,
> the inputs are all concatenated into monstrously long strings
> of text that are then submited as <hidden> inputs in HTML forms
> and parsed by the server-side ASP. This results in hideous strings
> that go on and on like
> johnsmith~1232^01^Yes^no~~|43|april
>
> etc. etc. This code is an incredible pain to maintain and update.
> There has got to be a better way to do this. I am required to
> use javascript and vbscript in ASP pages on the client side,
> and ASP pages for processing data on the server side. I can't
> switch to a different technology, or use .NET, or anything like
> that. I have to use JS and VBScript to get intricate and lengthy
> user inputs and submit them for processing. I would like to
> store these inputs in objects somehow and then get the data
> from those objects, if possible.


Everyone would like to be able to serialize client-side JavaScript
objects and send them to the server, unfortunately HTTP doesn't work
that way. To get the data to the server, you have to make an HTTP
request (usually GET or POST). The only thing you can send to the server
with a GET or POST are HTTP headers (which client-side JavaScript has no
access to without using the XML HTTP Request object) and the URL itself.

So at some point, you need to turn your complex data structure into
delimited text, or text attached to multiple attributes, or something,
to get it to the server.

The XML HTTP Request object does not change this, except it gives you
the ability to send custom HTTP headers and POST data without a <form>.

> If anyone could suggest a better method for doing all of this
> in javascript, even just to point me in the right direction, I would
> greatly appreciate it.


If you are trying to move complex client-side data structures to the
server, the only way to do it is to "serialize" it by doing what the
previous author of the site you must maintain has done, and then
reconstruct the data structure on the server from the "serialized" data
(delimited strings).

--
Grant Wagner <>
comp.lang.javascript FAQ - http://jibbering.com/faq

 
Reply With Quote
 
Jamie Jackson
Guest
Posts: n/a
 
      10-25-2004
On Mon, 25 Oct 2004 21:15:57 GMT, in comp.lang.javascript you wrote:

>Sven Neuberg wrote:
>
>Everyone would like to be able to serialize client-side JavaScript
>objects and send them to the server, unfortunately HTTP doesn't work
>that way. To get the data to the server, you have to make an HTTP
>request (usually GET or POST). The only thing you can send to the server
>with a GET or POST are HTTP headers (which client-side JavaScript has no
>access to without using the XML HTTP Request object) and the URL itself.


What about using WDDX to ease the parsing woes?

Jamie
 
Reply With Quote
 
Sven Neuberg
Guest
Posts: n/a
 
      10-25-2004

"McKirahan" <> wrote in message
news:4Zcfd.304707$MQ5.33947@attbi_s52...
>
> It sounds like the user fills in numerous fields and, on form submission,
> the data is concatenated into a single (hidden) field for passing to the
> server where it is parsed (perhaps using "Split()"), validated, and
> processed.
>


Yes, and not only that, there could be a dozen "sets" of this information,
all in one very long hidden field.


> One option is remove the concatenation+parsing and just refer to each file
> via "Request.Form("fieldname") on the server.
>


I'm not sure what you mean, sorry.


> Is any validation done on the client-side?
>


Yes, quite a bit.


> Is any manipulation done on the client-side?
>


Yes, because the user may choose to go back and edit some of the
fields, so there is quite a bit of parsing of the strings going on.

thank you,

sven


 
Reply With Quote
 
Sven Neuberg
Guest
Posts: n/a
 
      10-25-2004

"Jamie Jackson" <> wrote in message
news:...
>
>
> What about using WDDX to ease the parsing woes?
>
> Jamie



I have never heard of it, but now I am looking at www.openwddx.org to
see if it will help. Thank you for the suggestion.

sven



 
Reply With Quote
 
Joakim Braun
Guest
Posts: n/a
 
      10-26-2004
"Sven Neuberg" <> skrev i meddelandet
news:kHafd.6882$ ...
>
> Hi,
>
> I have been handed the task of updating and maintaining a web
> application, written in ASP and Javascript, that takes complex
> user inputs in HTML form and submits them to server-side ASP
> pages for processing. The problem is, the user inputs can
> become very complex, and the way this application was developed,
> the inputs are all concatenated into monstrously long strings
> of text that are then submited as <hidden> inputs in HTML forms
> and parsed by the server-side ASP. This results in hideous strings
> that go on and on like
> johnsmith~1232^01^Yes^no~~|43|april


<snip>

What happens if a user inputs one of the delimiting characters ("Joh|n
Smi~th")?

That problem is solved if you write Javascript to serialize/unserialize
arrays, and the same code in your server-side language.

For instance, say you collect form values into an array like:
var theThing = new Array("johnsmith", "Yes", 1232);

You could convert this into something like:
Array{key sz:1{0} string sz:9{johnsmith} key sz:1{1} string sz:3{Yes} key
sz:1{2} int sz:4{1232}}

You post it to the server, which reconstitutes the array. This would work
regardless of the input values and it's a bit easier to maintain.

Joakim Braun


 
Reply With Quote
 
Grant Wagner
Guest
Posts: n/a
 
      10-26-2004
Joakim Braun wrote:

> "Sven Neuberg" <> skrev i meddelandet
> news:kHafd.6882$ ...
> >
> > Hi,
> >
> > I have been handed the task of updating and maintaining a web
> > application, written in ASP and Javascript, that takes complex
> > user inputs in HTML form and submits them to server-side ASP
> > pages for processing. The problem is, the user inputs can
> > become very complex, and the way this application was developed,
> > the inputs are all concatenated into monstrously long strings
> > of text that are then submited as <hidden> inputs in HTML forms
> > and parsed by the server-side ASP. This results in hideous strings
> > that go on and on like
> > johnsmith~1232^01^Yes^no~~|43|april

>
> <snip>
>
> What happens if a user inputs one of the delimiting characters ("Joh|n
> Smi~th")?
>
> That problem is solved if you write Javascript to serialize/unserialize
> arrays, and the same code in your server-side language.
>
> For instance, say you collect form values into an array like:
> var theThing = new Array("johnsmith", "Yes", 1232);
>
> You could convert this into something like:
> Array{key sz:1{0} string sz:9{johnsmith} key sz:1{1} string sz:3{Yes} key
> sz:1{2} int sz:4{1232}}
>
> You post it to the server, which reconstitutes the array. This would work
> regardless of the input values and it's a bit easier to maintain.
>
> Joakim Braun


One last note about this, the Object#toSource() method is well-suited to the
task of serializing your object. Try the following code in any Gecko-based
browser (Firefox, Mozilla, Netscape 7+):

var o = new Object();
o.a = 1;
o.b = '2';
o.c = new Object();
o.c.d = 3;
o.c.e = '4';
alert(o.toSource());

Unfortunately, toSource() isn't supported in IE.

--
Grant Wagner <>
comp.lang.javascript FAQ - http://jibbering.com/faq

 
Reply With Quote
 
Sven Neuberg
Guest
Posts: n/a
 
      10-26-2004

"Joakim Braun" <> wrote in message
news:zkpfd.9001$...
>
>
> For instance, say you collect form values into an array like:
> var theThing = new Array("johnsmith", "Yes", 1232);
>
> You could convert this into something like:
> Array{key sz:1{0} string sz:9{johnsmith} key sz:1{1} string sz:3{Yes} key
> sz:1{2} int sz:4{1232}}
>
> You post it to the server, which reconstitutes the array. This would work
> regardless of the input values and it's a bit easier to maintain.
>



Thank you! I am going to look into this. It looks like it could be very
helpful.

sven



 
Reply With Quote
 
Sven Neuberg
Guest
Posts: n/a
 
      10-26-2004

"Grant Wagner" <> wrote in message
news:...
>
>
> Unfortunately, toSource() isn't supported in IE.
>


Unfortunately, IE is our target browser, and it is a decision that is
out of my control.

sven



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sanitizing user inputs in multiple languages Sam Perl Misc 2 04-05-2007 01:55 PM
[XML Schema] Content type of complex type definition with complex content Stanimir Stamenkov XML 2 10-25-2005 10:16 AM
Disable Back button for a particular inputs from user zyaam ASP .Net 2 12-29-2004 08:11 PM
For expert on complex loops (reposted) - complex looping problem news.amnet.net.au Java 1 04-13-2004 07:10 AM
Anybody know how I would code an error statement when a user inputs an invalid input. jeff regoord C Programming 10 09-13-2003 01:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57