Connecting Tech Pros Worldwide Forums | Help | Site Map

Hide form submit button value

k3pp0
Guest
 
Posts: n/a
#3: Jun 2 '08

re: Hide form submit button value


Hello.

Here's my example form:

<form method="get" action="">
<p>
<input type="radio" name="radio_example" id="radio1"
value="radio1_val" />
<label for="radio1">radio button one</label>
</p>
<p>
<input type="radio" name="radio_example" id="radio2"
value="radio2_val" />
<label for="radio2">radio button two</label>
</p>
<p>
<input type="submit" name="submitform" 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):
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?



Captain Paralytic
Guest
 
Posts: n/a
#1: Jun 2 '08
On 17 Apr, 10:48, Guillaume <ggra...@NOSPAM.gmail.com.INVALIDwrote:
Quote:
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!
Guillaume
Guest
 
Posts: n/a
#2: Jun 2 '08

re: Hide form submit button value


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

Regards,
--
Guillaume
Erwin Moller
Guest
 
Posts: n/a
#4: Jun 2 '08

re: Hide form submit button value


k3pp0 schreef:
Quote:
Hello.
>
Here's my example form:
>
<form method="get" action="">
<p>
<input type="radio" name="radio_example" id="radio1"
value="radio1_val" />
<label for="radio1">radio button one</label>
</p>
<p>
<input type="radio" name="radio_example" id="radio2"
value="radio2_val" />
<label for="radio2">radio button two</label>
</p>
<p>
<input type="submit" name="submitform" 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):
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...
that is just me.

Regards,
Erwin Moller
Michael Fesser
Guest
 
Posts: n/a
#5: Jun 2 '08

re: Hide form submit button value


..oO(Erwin Moller)
Quote:
Quote:
>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
Alexey Kulentsov
Guest
 
Posts: n/a
#6: Jun 2 '08

re: Hide form submit button value


k3pp0 wrote:
Quote:
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.removeChild(d);">
<INPUT NAME="toLeave">
<INPUT NAME="toDrop" TYPE="SUBMIT">
</FORM>
</BODY>
</HTML>
AnrDaemon
Guest
 
Posts: n/a
#7: Jun 27 '08

re: Hide form submit button value


Greetings, Alexey Kulentsov.
In reply to Your message dated Friday, April 18, 2008, 12:16:14,
Quote:
k3pp0 wrote:
Quote:
Quote:
>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?
Quote:
Just drop this control before submitting:
Quote:
<HTML>
<BODY>
<FORM onSubmit="var d=this.toDrop;d.parentNode.removeChild(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@freemail.ru>

Michael Fesser
Guest
 
Posts: n/a
#8: Jun 27 '08

re: Hide form submit button value


..oO(AnrDaemon)
Quote:
>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
AnrDaemon
Guest
 
Posts: n/a
#9: Jun 27 '08

re: Hide form submit button value


Greetings, Michael Fesser.
In reply to Your message dated Tuesday, June 10, 2008, 04:19:03,
Quote:
Quote:
>>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.
Quote:
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@freemail.ru>

Chetan Pandya
Guest
 
Posts: n/a
#10: Jun 27 '08

re: Hide form submit button value


AnrDaemon <anrdaemon@freemail.ruwrites:
Quote:
Quote:
Quote:
>>>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.
>
Quote:
>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
AnrDaemon
Guest
 
Posts: n/a
#11: Jun 27 '08

re: Hide form submit button value


Greetings, Chetan Pandya.
In reply to Your message dated Wednesday, June 11, 2008, 02:15:44,
Quote:
Quote:
Quote:
>>>>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.
>>
Quote:
>>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.
Quote:
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@freemail.ru>

Closed Thread