prefill form action based on button pressed

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

    #1

    prefill form action based on button pressed

    i have a form which i would like to input different "action" url depending
    on the button that was clicked.

    is there a way that javascript can prefill a defined action based on the
    button pressed?

    thanks!!!


  • David Dorward

    #2
    Re: prefill form action based on button pressed

    M wrote:
    [color=blue]
    > i have a form which i would like to input different "action" url depending
    > on the button that was clicked.
    >
    > is there a way that javascript can prefill a defined action based on the
    > button pressed?[/color]

    Not safely. The easiest way to do this is to have your form handler (i.e.
    the thing you have at the HTTP resource you reference in the action) look
    at which submit button was clicked (give your submit buttons the same name,
    then see which value makes it though) and then act accordingly.

    BTW - is your shift key broken?

    --
    David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is

    Comment

    • M

      #3
      Re: prefill form action based on button pressed

      no my shift key is not broken. do you have a problem reading all lowercase?


      "David Dorward" <dorward@yahoo. com> wrote in message
      news:d0c0jg$nuj $1$8300dec7@new s.demon.co.uk.. .[color=blue]
      >M wrote:
      >[color=green]
      >> i have a form which i would like to input different "action" url
      >> depending
      >> on the button that was clicked.
      >>
      >> is there a way that javascript can prefill a defined action based on the
      >> button pressed?[/color]
      >
      > Not safely. The easiest way to do this is to have your form handler (i.e.
      > the thing you have at the HTTP resource you reference in the action) look
      > at which submit button was clicked (give your submit buttons the same
      > name,
      > then see which value makes it though) and then act accordingly.
      >
      > BTW - is your shift key broken?
      >
      > --
      > David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
      > Home is where the ~/.bashrc is[/color]


      Comment

      • David Dorward

        #4
        Re: prefill form action based on button pressed

        M wrote:
        [color=blue]
        > no my shift key is not broken. do you have a problem reading all
        > lowercase?[/color]

        Most people find sentences that don't conform to the standard rules of
        grammer harder to read then those that do. Additionally, the convention on
        Usenet is not to place content in reverse chronological order.



        --
        David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
        Home is where the ~/.bashrc is

        Comment

        • M

          #5
          Re: prefill form action based on button pressed

          that must be some big stick up your butt.


          "David Dorward" <dorward@yahoo. com> wrote in message
          news:d0cu97$1km $1$8300dec7@new s.demon.co.uk.. .[color=blue]
          >M wrote:
          >[color=green]
          >> no my shift key is not broken. do you have a problem reading all
          >> lowercase?[/color]
          >
          > Most people find sentences that don't conform to the standard rules of
          > grammer harder to read then those that do. Additionally, the convention on
          > Usenet is not to place content in reverse chronological order.
          >
          > http://www.netmeister.org/news/learn2quote2.html#ss2.3
          >
          > --
          > David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
          > Home is where the ~/.bashrc is[/color]


          Comment

          • M

            #6
            Re: prefill form action based on button pressed

            well if anyone cares more about javascript than grammar and punctuation,
            although a simple find, document.locati on.href does the trick.

            <form method="post">

            <input name="button.ed itStock" type="button" value="edit"
            onclick="docume nt.location.hre f='#request.mys elf##xfa.edit#& mid=#attributes .mid#'">
            |
            <input name="button.de leteStock" type="button" value="delete"
            onclick="docume nt.location.hre f='#request.mys elf##xfa.delete #&mid=#attribut es.mid#'">
            |
            <input name="button.pr intLabels" type="button" value="print labels"
            onclick="docume nt.location.hre f='#request.mys elf##xfa.printL abels#&mid=#att ributes.mid#'">

            </form>

            thanks!

            todays date: 03/05/05


            "M" <m@m.com> wrote in message
            news:pjoWd.2066 $cN6.545@newsre ad1.news.pas.ea rthlink.net...[color=blue]
            > that must be some big stick up your butt.
            >
            >
            > "David Dorward" <dorward@yahoo. com> wrote in message
            > news:d0cu97$1km $1$8300dec7@new s.demon.co.uk.. .[color=green]
            >>M wrote:
            >>[color=darkred]
            >>> no my shift key is not broken. do you have a problem reading all
            >>> lowercase?[/color]
            >>
            >> Most people find sentences that don't conform to the standard rules of
            >> grammer harder to read then those that do. Additionally, the convention
            >> on
            >> Usenet is not to place content in reverse chronological order.
            >>
            >> http://www.netmeister.org/news/learn2quote2.html#ss2.3
            >>
            >> --
            >> David Dorward <http://blog.dorward.me .uk/>
            >> <http://dorward.me.uk/>
            >> Home is where the ~/.bashrc is[/color]
            >
            >[/color]


            Comment

            • David Dorward

              #7
              Re: prefill form action based on button pressed

              M wrote:
              [color=blue]
              > well if anyone cares more about javascript than grammar and punctuation,
              > although a simple find, document.locati on.href does the trick.[/color]

              It might "do the trick", but it doesn't so what you actually asked for. And
              it won't do the trick when a user who doesn't have a browser with
              JavaScript available and enabled turns up - which is why I suggested taking
              a more sensible approach when I responded to your original message. For
              some reason you decided to ignore the solution to your question in favour
              of treating my post script as an invitation to make a personal attack on
              me.

              Since it seems that your real problem seems to be about making a button act
              as a link, you should probably look into CSS instead ... and create a link
              that looks like a button.

              --
              David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
              Home is where the ~/.bashrc is

              Comment

              • Evertjan.

                #8
                Re: prefill form action based on button pressed

                M wrote on 05 mrt 2005 in comp.lang.javas cript:[color=blue]
                > todays date: 03/05/05[/color]

                Please do not toppost and please do not use ambiguous statements.

                For me today is 05/03/2005 [to many others it even is 06/03/2005]

                Best would be using something like 2005/03/05

                If you must say 03/05/05,
                not stating your residence [possibly] being in the US is a bad idea.

                --
                Evertjan.
                The Netherlands.
                (Replace all crosses with dots in my emailaddress)

                Comment

                Working...