function returning a string?

Michael Hamm

Usenet Archive
Joined
Jul 24, 2000
Messages
11
Reaction score
0
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
Fine print:
http://math.wustl.edu/~msh210/ ... legal.html
 

mscir

Usenet Archive
Joined
Dec 11, 2003
Messages
483
Reaction score
0
Michael Hamm wrote:
<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

Is this what you mean by less bytes? Not sure about browser/version support, but this works in my ie6, netscape 7.2, firefox 1.0.

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

MIke
 

RobB

Usenet Archive
Joined
Sep 7, 2003
Messages
587
Reaction score
0
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
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.
 

Michael Hamm

Usenet Archive
Joined
Jul 24, 2000
Messages
11
Reaction score
0
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
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

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,246
Members
248,133
Latest member
DujonT

Latest Threads

Top