Submit form with link

Discussion in 'HTML' started by Terence Parker, Jan 14, 2004.

  1. Hello,

    I wish to submit a form with a link instead of a submit button - but there's
    a catch : using the same form, I want to have different links that submit
    that form to different locations. Here's a simplification of what I have so
    far:

    <form name="SubmitUsers" method="POST" action="process.php">
    <input type="checkbox" name="username[]" value="Some value">
    <input type="checkbox" ........... >
    </form>

    <a href="javascript: void(0);" onclick="document.SubmitUsers.submit();return
    false;">

    - this link above will submit the form, but it will submit the form to
    "process.php" as defined in the initial <form> clause. What if I want
    another link that, say, submits to "process2.php" instead? But I want to be
    able to use the same checkboxes, so I don't want to have to redefine another
    form for this.

    Can this be done?

    Thanks!

    Terence
    Terence Parker, Jan 14, 2004
    #1
    1. Advertising

  2. Quoth the raven named Terence Parker:

    > I wish to submit a form with a link instead of a submit button -
    > but there's a catch : using the same form, I want to have different
    > links that submit that form to different locations. Here's a
    > simplification of what I have so far:
    >
    > <form name="SubmitUsers" method="POST" action="process.php"> <input
    > type="checkbox" name="username[]" value="Some value"> <input
    > type="checkbox" ........... > </form>
    >
    > <a href="javascript: void(0);"
    > onclick="document.SubmitUsers.submit();return false;">
    >
    > - this link above will submit the form, but it will submit the form
    > to "process.php" as defined in the initial <form> clause. What if I
    > want another link that, say, submits to "process2.php" instead? But
    > I want to be able to use the same checkboxes, so I don't want to
    > have to redefine another form for this.
    >
    > Can this be done?


    Based on your description, I would add a radio button above the one
    submit button, and have your process.php do what it does based on
    which radio button was ticked.

    Be sure to have none ticked by default.

    --
    -bts
    -This space intentionally left blank.
    Beauregard T. Shagnasty, Jan 14, 2004
    #2
    1. Advertising

  3. Terence Parker

    Ryan Stewart Guest

    "Terence Parker" <> wrote in message
    news:bu3u1l$...
    > Hello,
    >
    > I wish to submit a form with a link instead of a submit button - but

    there's
    > a catch : using the same form, I want to have different links that submit
    > that form to different locations. Here's a simplification of what I have

    so
    > far:
    >
    > <form name="SubmitUsers" method="POST" action="process.php">
    > <input type="checkbox" name="username[]" value="Some value">
    > <input type="checkbox" ........... >
    > </form>
    >
    > <a href="javascript: void(0);"

    onclick="document.SubmitUsers.submit();return
    > false;">
    >
    > - this link above will submit the form, but it will submit the form to
    > "process.php" as defined in the initial <form> clause. What if I want
    > another link that, say, submits to "process2.php" instead? But I want to

    be
    > able to use the same checkboxes, so I don't want to have to redefine

    another
    > form for this.
    >
    > Can this be done?
    >
    > Thanks!
    >
    > Terence


    I may be wrong, but can't you change the form's action? Something like:
    document.SubmitUsers.action="process2.php";

    That's just a wild guess, so you'll have to do some research, but I think
    it's possible.
    Ryan Stewart, Jan 14, 2004
    #3
  4. Terence Parker

    brucie Guest

    in post: <news:bu3u1l$>
    "Terence Parker" <> said:

    > I wish to submit a form with a link instead of a submit button


    not a good idea.

    > - but there's a catch : using the same form, I want to have different
    > links that submit that form to different locations.


    use two submit buttons, script redirects based on submit button pressed.

    > <a href="javascript: void(0);" onclick="document.SubmitUsers.submit();return
    > false;">


    that not going to do anything for people without JS


    --
    brucie
    brucie, Jan 14, 2004
    #4
  5. Terence Parker

    Ryan Stewart Guest

    "brucie" <> wrote in message
    news:bu4ekn$djj83$-berlin.de...
    > in post: <news:bu3u1l$>
    > "Terence Parker" <> said:
    >
    > > I wish to submit a form with a link instead of a submit button

    >
    > not a good idea.
    >
    > > - but there's a catch : using the same form, I want to have different
    > > links that submit that form to different locations.

    >
    > use two submit buttons, script redirects based on submit button pressed.
    >
    > > <a href="javascript: void(0);"

    onclick="document.SubmitUsers.submit();return
    > > false;">

    >
    > that not going to do anything for people without JS
    >
    >
    > --
    > brucie


    Well, some people think buttons are ugly and program for the vast majority
    of people who have scripting enabled. And some people are assured of a user
    base with scripting enabled.
    Ryan Stewart, Jan 14, 2004
    #5
  6. Terence Parker

    brucie Guest

    in post: <news:>
    "Ryan Stewart" <> said:

    >>> <a href="javascript: void(0);" onclick="document.SubmitUsers.submit()
    >>> ;return false;">


    >> that not going to do anything for people without JS


    > Well, some people think buttons are ugly


    use css to style the button to look like a text link, its simple. (i
    don't recommended it). scripting support not required.

    > and program for the vast majority of people who have scripting
    > enabled.


    you're an idiot. it simply doesn't make sense to implement a solution
    that will break for some people when there is a solution that will work
    for everyone.

    --
    brucie - i usenet nude
    brucie, Jan 15, 2004
    #6
  7. Terence Parker

    Mark Parnell Guest

    On Wed, 14 Jan 2004 16:58:30 -0600, Ryan Stewart "Ryan Stewart"
    <> declared in alt.html:
    > "brucie" <> wrote in message
    > news:bu4ekn$djj83$-berlin.de...
    >> in post: <news:bu3u1l$>
    >> "Terence Parker" <> said:
    >>
    >>> I wish to submit a form with a link instead of a submit button

    >>
    >> not a good idea.
    >>
    >>> <a href="javascript: void(0);"

    > onclick="document.SubmitUsers.submit();return
    >>> false;">

    >>
    >> that not going to do anything for people without JS

    >
    > Well, some people think buttons are ugly


    Whether they are ugly or not, at least your users know what they are.

    > and program for the vast majority of people who have scripting enabled.


    Majority, yes. Vast majority? That's debatable. Most estimates say that
    around 15% (that's 1 in 20) of your site's visitors will have scripting
    disabled. That's a pretty significant portion, IMHO.

    And why do something that requires client-side scripting when it can be
    done just as easily without needing client-side scripting?

    > And some people are assured of a user base with scripting enabled.


    Then they specify that in their original post. The OP did not, so as per
    the FAQ, we assume they are talking in a www context.

    --
    Mark Parnell
    http://www.clarkecomputers.com.au
    Mark Parnell, Jan 15, 2004
    #7
  8. Terence Parker

    brucie Guest

    in post: <news:>
    "Ryan Stewart" <> said:

    >>> <a href="javascript: void(0);" onclick="document.SubmitUsers.submit()
    >>> ;return false;">


    >> that not going to do anything for people without JS


    > Well, some people think buttons are ugly


    perhaps you could identify for me which is the text link that requires
    JS to work and which is the submit button that doesn't need anything to
    work in this image:

    http://moreshit.bruciesusenetshit.info/submit01.png [1k]


    --
    brucie - i usenet nude
    brucie, Jan 15, 2004
    #8
  9. Terence Parker

    Ryan Stewart Guest

    "brucie" <> wrote in message
    news:bu4so5$dt9m0$-berlin.de...
    > in post: <news:>
    > "Ryan Stewart" <> said:
    >
    > >>> <a href="javascript: void(0);" onclick="document.SubmitUsers.submit()
    > >>> ;return false;">

    >
    > >> that not going to do anything for people without JS

    >
    > > Well, some people think buttons are ugly

    >
    > perhaps you could identify for me which is the text link that requires
    > JS to work and which is the submit button that doesn't need anything to
    > work in this image:
    >
    > http://moreshit.bruciesusenetshit.info/submit01.png [1k]


    The top one is the button.

    Sorry, I've gotta get used to the fact that this NG doesn't tell people what
    they ask, but what they should do instead. I agree that a button is a better
    solution to his problem. I also think you could be less inflammatory about
    such things, as you are a good source of information in this group, but
    c'est la vie.
    Ryan Stewart, Jan 15, 2004
    #9
  10. Terence Parker

    rf Guest

    "Ryan Stewart" <> wrote in message
    news:...
    > "brucie" <> wrote in message
    > news:bu4ekn$djj83$-berlin.de...
    > > in post: <news:bu3u1l$>
    > > "Terence Parker" <> said:
    > >

    > Well, some people think buttons are ugly


    The "vast majority" of viewers think that buttons are just fine. They are
    used to them and used to clicking on them.

    Make a button look like something else and they will probably not click on
    it and declare the site broken.

    This is how a standard gui works. It contains, amongst other things,
    familiar buttons.

    Cheers
    Richard.
    rf, Jan 15, 2004
    #10
  11. Mark Parnell wrote:

    > Majority, yes. Vast majority? That's debatable. Most estimates say that
    > around 15% (that's 1 in 20) of your site's visitors will have scripting
    > disabled.


    Did you fail Maths at school? 15% is closer to one in seven.

    Ryan Stewart wrote:
    >> Well, some people think buttons are ugly


    Then include the proper button in the HTML, but use Javascript to hide it.
    That way, non-Javascript users can still see and use the button.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me - http://www.goddamn.co.uk/tobyink/?page=132
    Toby A Inkster, Jan 15, 2004
    #11
  12. Terence Parker

    Whitecrest Guest

    In article <>,
    says...
    > Well, some people think buttons are ugly and program for the vast majority
    > of people who have scripting enabled. And some people are assured of a user
    > base with scripting enabled.


    At the very least, you can guess that it will work on 85% of your
    visitors, and if it is a product or site where you probably would not go
    while surfing at work (where some companies, though I never worked for
    one, might turn javascript off) then that percentage would improve even
    more because you have removed business surfers from the pool of possible
    visitors.

    Decisions decisions. Will making Javascript a requirement, actually
    increase the number of people that use your site because you can now
    present it to the user the way they want to see it, but you may make it
    so a few of them can't see it.

    So is it better to loose 15% because they can not see it (actually less
    because some people will turn it on to use your site), or possibly loose
    up to 85% because they don't like the way you have to present your
    content just to please the 15%.

    This is the decision you have to make. I personally choose to please
    the 85%. Remember, no one will ever turn off Javascript when they come
    to your site, but if they need the content they may will turn it on.
    Even our local zealots admit to turning it on when they need to.

    --
    Whitecrest Entertainment
    www.whitecrestent.com
    Whitecrest, Jan 15, 2004
    #12
  13. Terence Parker

    Mark Parnell Guest

    On Thu, 15 Jan 2004 07:34:16 +0000, Toby A Inkster
    <> declared in alt.html:
    > Mark Parnell wrote:
    >
    >> around 15% (that's 1 in 20) of your site's visitors will have scripting
    >> disabled.

    >
    > Did you fail Maths at school? 15% is closer to one in seven.
    >


    You're right of course. I didn't fail Maths (actually I did very well),
    but evidently it has been too long. :)

    --
    Mark Parnell
    http://www.clarkecomputers.com.au
    Mark Parnell, Jan 15, 2004
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page