Hide form submit button value

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

    Hide form submit button value

    Hello.

    Here's my example form:

    <form method="get" action="">
    <p>
    <input type="radio" name="radio_exa mple" id="radio1"
    value="radio1_v al" />
    <label for="radio1">ra dio button one</label>
    </p>
    <p>
    <input type="radio" name="radio_exa mple" id="radio2"
    value="radio2_v al" />
    <label for="radio2">ra dio button two</label>
    </p>
    <p>
    <input type="submit" name="submitfor m" id="submitform "
    value="caption" />
    </p>
    </form>

    When submitting this form with the specified GET method you'll get an
    URL like this (http://foo.bar/form.php being the form's URL):


    Now I want to avoid that the submit button's value is also passed to
    the URL, so I would only get this URL when submitting the form:


    Is this possible?
  • Erwin Moller

    #2
    Re: Hide form submit button value

    k3pp0 schreef:
    Hello.
    >
    Here's my example form:
    >
    <form method="get" action="">
    <p>
    <input type="radio" name="radio_exa mple" id="radio1"
    value="radio1_v al" />
    <label for="radio1">ra dio button one</label>
    </p>
    <p>
    <input type="radio" name="radio_exa mple" id="radio2"
    value="radio2_v al" />
    <label for="radio2">ra dio button two</label>
    </p>
    <p>
    <input type="submit" name="submitfor m" id="submitform "
    value="caption" />
    </p>
    </form>
    >
    When submitting this form with the specified GET method you'll get an
    URL like this (http://foo.bar/form.php being the form's URL):

    >
    Now I want to avoid that the submit button's value is also passed to
    the URL, so I would only get this URL when submitting the form:

    >
    Is this possible?
    Hi,

    Leave out the name of the submitbutton.
    I think only named formelements are actually send.

    I must add I cannot see any reason to leave that part out, but well...
    that is just me.

    Regards,
    Erwin Moller

    Comment

    • Guillaume

      #3
      Re: Hide form submit button value

      Erwin Moller a écrit :
      I think only named formelements are actually send.
      I confirm, plus I add that it's not PHP related at all ;)

      Regards,
      --
      Guillaume

      Comment

      • Captain Paralytic

        #4
        Re: Hide form submit button value

        On 17 Apr, 10:48, Guillaume <ggra...@NOSPAM .gmail.com.INVA LIDwrote:
        Erwin Moller a écrit :I think only named formelements are actually send.
        >
        I confirm, plus I add that it's not PHP related at all ;)
        >
        Regards,
        --
        Guillaume
        Hey Guillaume, that's Jerry's job!

        Comment

        • Michael Fesser

          #5
          Re: Hide form submit button value

          ..oO(Erwin Moller)
          >When submitting this form with the specified GET method you'll get an
          >URL like this (http://foo.bar/form.php being the form's URL):
          >http://foo.bar/form.php?radio_exampl...itform=caption
          >>
          >Now I want to avoid that the submit button's value is also passed to
          >the URL, so I would only get this URL when submitting the form:
          >http://foo.bar/form.php?radio_example=radio1_val
          >>
          >Is this possible?
          >
          >Hi,
          >
          >Leave out the name of the submitbutton.
          >I think only named formelements are actually send.
          >
          >I must add I cannot see any reason to leave that part out, but well...
          It keeps the URL shorter and is not really necessary for the form
          processing.

          Micha

          Comment

          • Alexey Kulentsov

            #6
            Re: Hide form submit button value

            k3pp0 wrote:
            Now I want to avoid that the submit button's value is also passed to
            the URL, so I would only get this URL when submitting the form:

            >
            Is this possible?
            Just drop this control before submitting:

            <HTML>
            <BODY>
            <FORM onSubmit="var d=this.toDrop;d .parentNode.rem oveChild(d);">
            <INPUT NAME="toLeave">
            <INPUT NAME="toDrop" TYPE="SUBMIT">
            </FORM>
            </BODY>
            </HTML>

            Comment

            • AnrDaemon

              #7
              Re: Hide form submit button value

              Greetings, Alexey Kulentsov.
              In reply to Your message dated Friday, April 18, 2008, 12:16:14,
              k3pp0 wrote:
              >Now I want to avoid that the submit button's value is also passed to
              >the URL, so I would only get this URL when submitting the form:
              >http://foo.bar/form.php?radio_example=radio1_val
              >>
              >Is this possible?
              Just drop this control before submitting:
              <HTML>
              <BODY>
              <FORM onSubmit="var d=this.toDrop;d .parentNode.rem oveChild(d);">
              <INPUT NAME="toLeave">
              <INPUT NAME="toDrop" TYPE="SUBMIT">
              </FORM>
              </BODY>
              </HTML>
              Why not get it straight?

              <HTML>
              <BODY>
              <FORM>
              <INPUT NAME="toLeave" value="Form data goes here"/>
              <INPUT TYPE="SUBMIT" value="Click me!"/>
              </FORM>
              </BODY>
              </HTML>

              Rule is simple: don't give name to element if you do not want to see it's
              value passed to the script...

              And it is not entirely PHP question... But it is related to PHP as you must
              know what kind of data you will get from what kind of form elements...

              Note: unchecked checkboxes does not provide any data to server too. If you
              want to see them even if they are not checked, that's work for some kind
              of javascript in form processing.


              --
              Sincerely Yours, AnrDaemon <anrdaemon@free mail.ru>

              Comment

              • Michael Fesser

                #8
                Re: Hide form submit button value

                ..oO(AnrDaemon)
                >Note: unchecked checkboxes does not provide any data to server too. If you
                >want to see them even if they are not checked, that's work for some kind
                >of javascript in form processing.
                Nope, JS is unreliable. You should use some better server-side form
                processing to keep track of the initial checkbox value. If it's then
                missing in the form submission, you can safely assume it was unchecked.

                Micha

                Comment

                • AnrDaemon

                  #9
                  Re: Hide form submit button value

                  Greetings, Michael Fesser.
                  In reply to Your message dated Tuesday, June 10, 2008, 04:19:03,
                  >>Note: unchecked checkboxes does not provide any data to server too. If you
                  >>want to see them even if they are not checked, that's work for some kind
                  >>of javascript in form processing.
                  Nope, JS is unreliable. You should use some better server-side form
                  processing to keep track of the initial checkbox value. If it's then
                  missing in the form submission, you can safely assume it was unchecked.
                  Interesting offer... can't remember if I have tested such possibility...
                  Ok, tested... it does not change the core issue. If you have some value
                  assigned to checkbox, it will be sent to script instead of default "on" text.
                  And that's all. I will not rely on that value in any of my project, just in
                  case some lame browser will eventually send me "on" instead of that value.


                  --
                  Sincerely Yours, AnrDaemon <anrdaemon@free mail.ru>

                  Comment

                  • Chetan Pandya

                    #10
                    Re: Hide form submit button value

                    AnrDaemon <anrdaemon@free mail.ruwrites:
                    >>>Note: unchecked checkboxes does not provide any data to server too. If you
                    >>>want to see them even if they are not checked, that's work for some kind
                    >>>of javascript in form processing.
                    >
                    >Nope, JS is unreliable. You should use some better server-side form
                    >processing to keep track of the initial checkbox value. If it's then
                    >missing in the form submission, you can safely assume it was unchecked.
                    >
                    Interesting offer... can't remember if I have tested such possibility...
                    Ok, tested... it does not change the core issue. If you have some value
                    assigned to checkbox, it will be sent to script instead of default "on" text.
                    And that's all. I will not rely on that value in any of my project, just in
                    case some lame browser will eventually send me "on" instead of that value.
                    Quite the opposite. It would appear that "on" is a default value being used if
                    you fail to provide one. If you don't want to rely on the values, perhaps the
                    simpler solution is to just check if the corresponding "name" is set. Note,
                    however, that checkboxes are similar to radio boxes and normally all radio
                    boxes in a group are given the same name and different values.


                    --
                    Chetan

                    Comment

                    • AnrDaemon

                      #11
                      Re: Hide form submit button value

                      Greetings, Chetan Pandya.
                      In reply to Your message dated Wednesday, June 11, 2008, 02:15:44,
                      >>>>Note: unchecked checkboxes does not provide any data to server too. If you
                      >>>>want to see them even if they are not checked, that's work for some kind
                      >>>>of javascript in form processing.
                      >>
                      >>Nope, JS is unreliable. You should use some better server-side form
                      >>processing to keep track of the initial checkbox value. If it's then
                      >>missing in the form submission, you can safely assume it was unchecked.
                      >>
                      >Interesting offer... can't remember if I have tested such possibility...
                      >Ok, tested... it does not change the core issue. If you have some value
                      >assigned to checkbox, it will be sent to script instead of default "on" text.
                      >And that's all. I will not rely on that value in any of my project, just in
                      >case some lame browser will eventually send me "on" instead of that value.
                      Quite the opposite. It would appear that "on" is a default value being used if
                      you fail to provide one. If you don't want to rely on the values, perhaps the
                      simpler solution is to just check if the corresponding "name" is set. Note,
                      however, that checkboxes are similar to radio boxes and normally all radio
                      boxes in a group are given the same name and different values.
                      We may have long discussion about relations between different web controls :)
                      But i'd better stop it with a simple statement:
                      Use what you think suits your needs better, but don't forget to carefully
                      check values passed to you as like they contains some smelly crap.


                      --
                      Sincerely Yours, AnrDaemon <anrdaemon@free mail.ru>

                      Comment

                      Working...