473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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?
Jun 2 '08 #1
10 7380
k3pp0 schreef:
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
Jun 2 '08 #2
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
Jun 2 '08 #3
On 17 Apr, 10:48, Guillaume <ggra...@NOSPAM.gmail.com.INVALIDwrote:
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!
Jun 2 '08 #4
..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
Jun 2 '08 #5
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.removeChild(d);">
<INPUT NAME="toLeave">
<INPUT NAME="toDrop" TYPE="SUBMIT">
</FORM>
</BODY>
</HTML>
Jun 2 '08 #6
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.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 <an*******@freemail.ru>

Jun 27 '08 #7
..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
Jun 27 '08 #8
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 <an*******@freemail.ru>

Jun 27 '08 #9
AnrDaemon <an*******@freemail.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
Jun 27 '08 #10
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 <an*******@freemail.ru>

Jun 27 '08 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Owen Funkhouser | last post by:
I have a form with three radio options. And I have three buttons: <input type="submit" name="mainform_action" value="Edit Data"> <input type="submit" name="mainform_action" value="View Data">...
3
by: earl | last post by:
Hey Say I have two <form> on a page like this : <form action="private.asp" method="post" name="form1"> // code <input type=submit value="submit" name="submit"> </form> <form...
15
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and...
1
by: Don Grover | last post by:
I have a table thats wrapped in a div tag, that when user selects 1 of 2 radio buttons it hides or shows table, this works ok. But I want to set the table show hide on what the existing state of...
9
by: sergio | last post by:
Hi all, I have created the following script that will show/hide a menu based on checkboxes. It works fine in Opera but not on IE6! Does anybody knows a workaround this problem? Thanks for your...
10
by: DettCom | last post by:
Hello, I would like to be able to display or hide fields based on whether a specific Yes/No radio button is selected. This is in conjunction with a posting a just made here in the same group...
5
by: Zambien | last post by:
Hi all, Here's my problem. I have tables that are using the menu/submenu idea for hiding rows. This works fine in IE (of course) and does show/hide correctly in netscape, but as soon as the...
12
by: ATS | last post by:
I need to hide/reveal parts of a web page using javascript. I think I can do with using the <span> tag, but I've been away from it for a while and don't remember. Any pointers, examples?
4
by: devine | last post by:
Hi All, I am VERY new to Javascript. I have been provided with some code, which will enable me to hide/show a text area and change a submit button dependant on a check box. <!DOCTYPE html...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.