Submit only once.

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

    Submit only once.

    Hello,

    I have a form which allow to submit a file, I'd like to block the submit
    buton once it has been clicked, so I tried:

    function SubmitNow(item) {
    if(item.value== "Please wait") {
    return false ;
    } else {
    item.value="Ple ase wait" ;
    item.form.submi t ;
    }
    }

    With inside the submit buton:

    <input class=submit type=submit value=Valid name=submitbtn
    onClick="Submit Now(this);">

    But it does not work :( We can send several times the same file...

    Any idea ?

    Thanks,
    Vincent.

  • Stuart Palmer

    #2
    Re: Submit only once.

    This might be a nasty idea but what about putting the button in a div and
    when it's clicked hide the dive so the button can't be repressed (as it's
    then hidden)
    Just my initial thought.

    Stu

    "Vincent M." <cult@free.fr > wrote in message
    news:3fc0574b$0 $26816$636a55ce @news.free.fr.. .[color=blue]
    > Hello,
    >
    > I have a form which allow to submit a file, I'd like to block the submit
    > buton once it has been clicked, so I tried:
    >
    > function SubmitNow(item) {
    > if(item.value== "Please wait") {
    > return false ;
    > } else {
    > item.value="Ple ase wait" ;
    > item.form.submi t ;
    > }
    > }
    >
    > With inside the submit buton:
    >
    > <input class=submit type=submit value=Valid name=submitbtn
    > onClick="Submit Now(this);">
    >
    > But it does not work :( We can send several times the same file...
    >
    > Any idea ?
    >
    > Thanks,
    > Vincent.
    >[/color]


    Comment

    • Janwillem Borleffs

      #3
      Re: Submit only once.


      "Vincent M." <cult@free.fr > schreef in bericht
      news:3fc0574b$0 $26816$636a55ce @news.free.fr.. .[color=blue]
      >
      > But it does not work :( We can send several times the same file...
      >
      > Any idea ?
      >[/color]

      <form onsubmit="submi tbtn.disabled=t rue">


      JW



      Comment

      • Lasse Reichstein Nielsen

        #4
        Re: Submit only once.

        "Vincent M." <cult@free.fr > writes:
        [color=blue]
        > I have a form which allow to submit a file, I'd like to block the
        > submit buton once it has been clicked, so I tried:[/color]

        Highly annoying! I sometimes use a web site where they do that. I
        submit something for a search, and then later use the back button to
        get back and do another search, but it doesn't work. Do I have to
        reload the page and lose the entered data.

        How about just using a confirm dialog asking "Are you sure you want
        to submit this form more than once?"?
        [color=blue]
        > function SubmitNow(item) {
        > if(item.value== "Please wait") {
        > return false ;[/color]

        i.e.: return confirm("Are you sure ... more than once?");
        [color=blue]
        > } else {
        > item.value="Ple ase wait" ;
        > item.form.submi t ;[/color]

        This line does nothing. It doesn't call the functions. It doesn't
        have to either, since the function returns undefined, so the normal
        effect of the click should take effect. I recommend keeping it
        this way. I.e., just drop that line.
        [color=blue]
        > }
        > }[/color]


        [color=blue]
        > With inside the submit buton:
        >
        > <input class=submit type=submit value=Valid name=submitbtn
        > onClick="Submit Now(this);">[/color]

        You don't return the result of SubmitNow, so the return false is
        irrelevant. Change it to
        onclick="return SubmitNow(this) "
        [color=blue]
        > But it does not work :( We can send several times the same file...[/color]

        You could even remember the names of the files that have already
        been sent and only warn if the same file is sent twice.

        /L
        --
        Lasse Reichstein Nielsen - lrn@hotpop.com
        DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
        'Faith without judgement merely degrades the spirit divine.'

        Comment

        Working...