help with onclick submit

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

    help with onclick submit

    In an unnamed form, unnamed because it only submits an email address, I'm
    trying to have the submit button clear the "e-mail" text value in the
    textbox.

    On the submit button I have the following:

    onClick="if(thi s.form['e-mail'].value=='e-mail')this.form['e-mail'].value=''"

    But it does not seem to work. Any ideas or suggestions?

    Thanks in advance!


  • web.dev

    #2
    Re: help with onclick submit


    John wrote:[color=blue]
    > In an unnamed form, unnamed because it only submits an email address, I'm
    > trying to have the submit button clear the "e-mail" text value in the
    > textbox.
    >
    > On the submit button I have the following:
    >
    > onClick="if(thi s.form['e-mail'].value=='e-mail')this.form['e-mail'].value=''"
    >
    > But it does not seem to work. Any ideas or suggestions?
    >
    > Thanks in advance![/color]

    You are accessing the form elements incorrectly. Try the following
    instead:

    this.form.eleme nts['e-mail'].value

    Comment

    • John

      #3
      Re: help with onclick submit


      "web.dev" <web.dev.cs@gma il.com> wrote in message
      news:1127939613 .355255.231240@ g47g2000cwa.goo glegroups.com.. .[color=blue]
      >
      > You are accessing the form elements incorrectly. Try the following
      > instead:
      >
      > this.form.eleme nts['e-mail'].value
      >[/color]

      Thanks but it does not seem to work.

      This here works:

      <input type="text" name="email" value="e-mail"
      onClick="if(thi s.value=='e-mail')this.valu e=''">

      Then right below I have the line for my submit button as per your
      suggestion:

      <input type="submit" value="Go!"
      onClick="if(thi s.form.elements['e-mail'].value=='e-mail')this.form .elements['e-mail'].value=''">

      Unfortunately it's not working.

      Any other ideas?

      Thanks!


      Comment

      • web.dev

        #4
        Re: help with onclick submit


        John wrote:[color=blue]
        > "web.dev" <web.dev.cs@gma il.com> wrote in message
        > news:1127939613 .355255.231240@ g47g2000cwa.goo glegroups.com.. .[color=green]
        > >
        > > You are accessing the form elements incorrectly. Try the following
        > > instead:
        > >
        > > this.form.eleme nts['e-mail'].value
        > >[/color]
        >
        > Thanks but it does not seem to work.
        >
        > This here works:
        >
        > <input type="text" name="email" value="e-mail"
        > onClick="if(thi s.value=='e-mail')this.valu e=''">
        >
        > Then right below I have the line for my submit button as per your
        > suggestion:
        >
        > <input type="submit" value="Go!"
        > onClick="if(thi s.form.elements['e-mail'].value=='e-mail')this.form .elements['e-mail'].value=''">
        >
        > Unfortunately it's not working.
        >
        > Any other ideas?
        >
        > Thanks![/color]

        Sorry for the confusion, when you first posted I had thought the name
        of your input element was "e-mail". Try the same solution this time
        replacing 'e-mail' with 'email':

        this.form.eleme nts['email'].value

        Comment

        • John

          #5
          Re: help with onclick submit


          "web.dev" <web.dev.cs@gma il.com> wrote in message
          news:1127941698 .833670.107860@ g14g2000cwa.goo glegroups.com.. .[color=blue]
          >
          > Sorry for the confusion, when you first posted I had thought the name
          > of your input element was "e-mail". Try the same solution this time
          > replacing 'e-mail' with 'email':
          >
          > this.form.eleme nts['email'].value
          >[/color]

          Thanks but it's still not working...



          Comment

          • web.dev

            #6
            Re: help with onclick submit


            John wrote:[color=blue]
            > "web.dev" <web.dev.cs@gma il.com> wrote in message
            > news:1127941698 .833670.107860@ g14g2000cwa.goo glegroups.com.. .[color=green]
            > >
            > > Sorry for the confusion, when you first posted I had thought the name
            > > of your input element was "e-mail". Try the same solution this time
            > > replacing 'e-mail' with 'email':
            > >
            > > this.form.eleme nts['email'].value
            > >[/color]
            >
            > Thanks but it's still not working...[/color]

            The current action is still submitting the form. The onClick even
            expects a boolean value to be returned. To see the expected result you
            are looking for, do the following:

            <input type="submit" value="Go!"
            onClick="if(thi s.form.elements['email'].value=='email' ){this.form.ele ments['email'].value='';}
            return false;">

            Comment

            • John

              #7
              Re: help with onclick submit


              "web.dev" <web.dev.cs@gma il.com> wrote in message
              news:1127942979 .250346.74860@g 44g2000cwa.goog legroups.com...[color=blue]
              >
              > The current action is still submitting the form. The onClick even
              > expects a boolean value to be returned. To see the expected result you
              > are looking for, do the following:
              >
              > <input type="submit" value="Go!"
              > onClick="if(thi s.form.elements['email'].value=='email' ){this.form.ele ments['email'].value='';}
              > return false;">
              >[/color]

              Thanks, it makes sense, but it's still not working. I tried changing the
              value from email to e-mail as that's the value in the previous statement is
              but still nothing.


              Comment

              • Mick White

                #8
                Re: help with onclick submit

                John wrote:[color=blue]
                > In an unnamed form, unnamed because it only submits an email address, I'm
                > trying to have the submit button clear the "e-mail" text value in the
                > textbox.
                >
                > On the submit button I have the following:
                >
                > onClick="if(thi s.form['e-mail'].value=='e-mail')this.form['e-mail'].value=''"
                >
                > But it does not seem to work. Any ideas or suggestions?
                >[/color]


                What do you expect to happen when you click the submit button? You want
                to submit the email value, don't you?
                Mick

                Comment

                • Lee

                  #9
                  Re: help with onclick submit

                  web.dev said:[color=blue]
                  >
                  >
                  >John wrote:[color=green]
                  >> "web.dev" <web.dev.cs@gma il.com> wrote in message
                  >> news:1127941698 .833670.107860@ g14g2000cwa.goo glegroups.com.. .[color=darkred]
                  >> >
                  >> > Sorry for the confusion, when you first posted I had thought the name
                  >> > of your input element was "e-mail". Try the same solution this time
                  >> > replacing 'e-mail' with 'email':
                  >> >
                  >> > this.form.eleme nts['email'].value
                  >> >[/color]
                  >>
                  >> Thanks but it's still not working...[/color]
                  >
                  >The current action is still submitting the form. The onClick even
                  >expects a boolean value to be returned. To see the expected result you
                  >are looking for, do the following:
                  >
                  ><input type="submit" value="Go!"
                  >onClick="if(th is.form.element s['email'].value=='email' ){this.form.ele ments['email'].value='';}
                  >return false;">[/color]

                  Better:

                  Never, ever, use the onclick handler of a submit button.
                  Use the onsubmit handler of the form tag, instead.

                  Comment

                  • John

                    #10
                    Re: help with onclick submit


                    "Mick White" <mwhite13BOGUS@ rochester.rr.co m> wrote in message
                    news:hnE_e.9291 $7b6.6076@twist er.nyroc.rr.com ...
                    [color=blue]
                    >
                    > What do you expect to happen when you click the submit button? You want
                    > to submit the email value, don't you?
                    > Mick[/color]

                    Yes, but not if the email value == the initial value "e-mail"

                    In other words, I don't want an email address called "e-mail" to be
                    submitted so, so when they try to hit submit, the words "e-mail" go away
                    from the textfield.


                    Comment

                    • John

                      #11
                      Re: help with onclick submit


                      "Lee" <REM0VElbspamtr ap@cox.net> wrote in message
                      news:dhf2pv02ok 4@drn.newsguy.c om...[color=blue]
                      >
                      > Better:
                      >
                      > Never, ever, use the onclick handler of a submit button.
                      > Use the onsubmit handler of the form tag, instead.
                      >[/color]

                      Only problem with that is that the user never sees the text "e-mail"
                      disappear if it has to be submitted. Rather, I'd want them to see the text
                      disappear when they click on the submit button.This way, if the form is
                      submitted, then a blank address gets emailed instead of "email" being
                      submitted as an email address.


                      Comment

                      • ASM

                        #12
                        Re: help with onclick submit

                        John a écrit :[color=blue]
                        > "web.dev" <web.dev.cs@gma il.com> wrote in message
                        > news:1127942979 .250346.74860@g 44g2000cwa.goog legroups.com...[color=green]
                        >>
                        >><input type="submit" value="Go!"
                        >>onClick="if(t his.form.elemen ts['email'].value=='email' ){this.form.ele ments['email'].value='';}
                        >>return false;">[/color]
                        >
                        > Thanks, it makes sense, but it's still not working. I tried changing the
                        > value from email to e-mail as that's the value in the previous statement is
                        > but still nothing.[/color]

                        <form action="foo.htm "
                        onsubmit="if(th is.email.value= ='e-mail'){
                        this.email.valu e='';
                        return false;
                        }
                        else
                        return true;">
                        <input type=text name="email" value="e-mail">
                        <input type=submit value=GO>
                        </form>

                        --
                        Stephane Moriaux et son [moins] vieux Mac

                        Comment

                        • Lee

                          #13
                          Re: help with onclick submit

                          John said:[color=blue]
                          >
                          >
                          >"Lee" <REM0VElbspamtr ap@cox.net> wrote in message
                          >news:dhf2pv02o k4@drn.newsguy. com...[color=green]
                          >>
                          >> Better:
                          >>
                          >> Never, ever, use the onclick handler of a submit button.
                          >> Use the onsubmit handler of the form tag, instead.
                          >>[/color]
                          >
                          >Only problem with that is that the user never sees the text "e-mail"
                          >disappear if it has to be submitted. Rather, I'd want them to see the text
                          >disappear when they click on the submit button.This way, if the form is
                          >submitted, then a blank address gets emailed instead of "email" being
                          >submitted as an email address.[/color]

                          Well, if you're not actually submitting anything, don't freaking use
                          a submit button. Use a regular button.

                          Comment

                          • John

                            #14
                            Re: help with onclick submit


                            "Lee" <REM0VElbspamtr ap@cox.net> wrote in message
                            news:dhf78d04f5 @drn.newsguy.co m...
                            [color=blue]
                            > Well, if you're not actually submitting anything, don't freaking use
                            > a submit button. Use a regular button.
                            >[/color]

                            It *is* submitting something, an email address. But if the email address is
                            "email" I want it blank.


                            Comment

                            • John

                              #15
                              Re: help with onclick submit


                              "ASM" <stephanemoriau x.NoAdmin@wanad oo.fr.invalid> wrote in message
                              news:433b1d75$0 $1000$8fcfb975@ news.wanadoo.fr ...[color=blue]
                              >
                              > <form action="foo.htm "
                              > onsubmit="if(th is.email.value= ='e-mail'){
                              > this.email.valu e='';
                              > return false;
                              > }
                              > else
                              > return true;">
                              > <input type=text name="email" value="e-mail">
                              > <input type=submit value=GO>
                              > </form>[/color]


                              Thanks! :-)


                              Comment

                              Working...