function returning a string?

M

Michael Hamm

I have the following:

<form onsubmit="this.q.value='from '+this.a.value+' to '+this.b.value;
this.a.value='PLEASE';this.b.value='WAIT';"
action="http://google.com/maps"><input type="submit" value="Find">
Google's directions from <input name="a" size="36"> to <input size="36"
name="b">.<input type="hidden" name="q"></form>

For brevity's sake, I wish to shorten this.x.value to f(x) (for each
x), assuming this comes out shorter (in bytes, not steps). Is there a way
to do so? (I'm only running this on my own computer, so I only care if it
runs in M$IE6.)

Tia,

Michael Hamm
AM, Math, Wash. U. St. Louis
(e-mail address removed) Fine print:
http://math.wustl.edu/~msh210/ ... legal.html
 
R

RobB

Michael said:
I have the following:

<form onsubmit="this.q.value='from '+this.a.value+' to '+this.b.value;
this.a.value='PLEASE';this.b.value='WAIT';"
action="http://google.com/maps"><input type="submit" value="Find">
Google's directions from <input name="a" size="36"> to <input size="36"
name="b">.<input type="hidden" name="q"></form>

For brevity's sake, I wish to shorten this.x.value to f(x) (for each
x), assuming this comes out shorter (in bytes, not steps). Is there a way
to do so? (I'm only running this on my own computer, so I only care if it
runs in M$IE6.)

Tia,

Michael Hamm
AM, Math, Wash. U. St. Louis
(e-mail address removed) Fine print:
http://math.wustl.edu/~msh210/ ... legal.html

Probably neater to do the entire process in a separate function:

function x(els)
{
els.q.value =
'from ' + els.a.value +
' to ' + els.b.value;
els.a.value = 'PLEASE';
els.b.value = 'WAIT';
}

<form.....onsubmit="x(this.elements)">

Could also go:

<form onsubmit="e=this.elements;v='value';e.q[v]='from '+e.a[v]+' to
'+e.b[v];
e.a[v]='PLEASE';e.b[v]='WAIT';"
action="http://google.com/maps">

....though it seems silly.
 
M

Michael Hamm

Could also go:

<form onsubmit="e=this.elements;v='value';e.q[v]='from '+e.a[v]+' to
'+e.b[v];
e.a[v]='PLEASE';e.b[v]='WAIT';"
action="http://google.com/maps">

...though it seems silly.

Yeah, I meant something like the latter. I was actually hoping for
something like

<form onsubmit="f[x]=this.x.value;f[q]='from '+f[a]+' to '+f;
f[a]='PLEASE';f='WAIT';" action="http://google.com/maps"><input
type="submit" value="Find">Google's directions from <input name="a"
size="36"> to <input size="36" name="b">.<input type="hidden" name="q">
</form>

Anything like that possible?

Michael Hamm
AM, Math, Wash. U. St. Louis
(e-mail address removed) Fine print:
http://math.wustl.edu/~msh210/ ... legal.html
 

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
473,998
Messages
2,570,242
Members
46,834
Latest member
vina0631

Latest Threads

Top