function returning a string?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Hamm

    function returning a string?

    I have the following:

    <form onsubmit="this. q.value='from '+this.a.value+ ' to '+this.b.value;
    this.a.value='P LEASE';this.b.v alue='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">.<inpu t 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
    msh210@math.wus tl.edu Fine print:
    http://math.wustl.edu/~msh210/ ... legal.html
  • mscir

    #2
    Re: function returning a string?

    Michael Hamm wrote:[color=blue]
    > <form onsubmit="this. q.value='from '+this.a.value+ ' to '+this.b.value;
    > this.a.value='P LEASE';this.b.v alue='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">.<inpu t 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[/color]

    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.val ue='from '+a.value+' to
    '+b.value;a.val ue='PLEASE';b.v alue='WAIT';" action="http://google.com/maps">
    <input type="submit" value="Find">&n bsp;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

    Comment

    • RobB

      #3
      Re: function returning a string?

      Michael Hamm wrote:[color=blue]
      > I have the following:
      >
      > <form onsubmit="this. q.value='from '+this.a.value+ ' to[/color]
      '+this.b.value;[color=blue]
      > this.a.value='P LEASE';this.b.v alue='WAIT';"
      > action="http://google.com/maps"><input type="submit" value="Find">
      > Google's directions from <input name="a" size="36"> to <input[/color]
      size="36"[color=blue]
      > name="b">.<inpu t type="hidden" name="q"></form>
      >
      > For brevity's sake, I wish to shorten this.x.value to f(x) (for[/color]
      each[color=blue]
      > x), assuming this comes out shorter (in bytes, not steps). Is there[/color]
      a way[color=blue]
      > to do so? (I'm only running this on my own computer, so I only care[/color]
      if it[color=blue]
      > runs in M$IE6.)
      >
      > Tia,
      >
      > Michael Hamm
      > AM, Math, Wash. U. St. Louis
      > msh210@math.wus tl.edu Fine print:
      > http://math.wustl.edu/~msh210/ ... legal.html[/color]

      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.....onsub mit="x(this.ele ments)">

      Could also go:

      <form onsubmit="e=thi s.elements;v='v alue';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.

      Comment

      • Michael  Hamm

        #4
        Re: function returning a string?

        On 24 Feb 2005 13:11:42 -0800, RobB <ferndoc9@hotma il.com> wrote, in part:[color=blue][color=green]
        > > <form onsubmit="this. q.value='from '+this.a.value+ ' to
        > > '+this.b.value; this.a.value='P LEASE';this.b.v alue='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">.<inpu t 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.)[/color][/color]
        <snip>[color=blue]
        > Could also go:
        >
        > <form onsubmit="e=thi s.elements;v='v alue';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.[/color]

        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[b];
        f[a]='PLEASE';f[b]='WAIT';" action="http://google.com/maps"><input
        type="submit" value="Find">Go ogle's directions from <input name="a"
        size="36"> to <input size="36" name="b">.<inpu t type="hidden" name="q">
        </form>

        Anything like that possible?

        Michael Hamm
        AM, Math, Wash. U. St. Louis
        msh210@math.wus tl.edu Fine print:
        http://math.wustl.edu/~msh210/ ... legal.html

        Comment

        Working...