473,399 Members | 3,919 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,399 software developers and data experts.

Getting button pressed

Hi

It is late and I am tired. I cannot remember how to check which of my
buttons on the form was pressed. There are all submit's.

Like

echo "P=".$_POST['btn_post1']; // and eventually using isset()

But how was it it was?
Aug 25 '08 #1
8 1691
jodleren wrote:
Hi

It is late and I am tired. I cannot remember how to check which of my
buttons on the form was pressed. There are all submit's.

Like

echo "P=".$_POST['btn_post1']; // and eventually using isset()

But how was it it was?
Unless you use javascript with 'onclick' to set a hidden variable, I
don't think there is a way of working out which submit button was pressed.

Aug 25 '08 #2
jodleren wrote:
Hi

It is late and I am tired. I cannot remember how to check which of my
buttons on the form was pressed. There are all submit's.

Like

echo "P=".$_POST['btn_post1']; // and eventually using isset()

But how was it it was?
The contents of $_POST['btn_post1'] will contain the contents of the
value= parameter of the pressed button.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 25 '08 #3
If I have a form

<form action="<?php $_SERVER['PHP_SELF'] ?>" method="get">

<input type="submit" name="sub" value="Submit1" />
<input type="submit" name="sub" value="Submit2" />

</form>
I could check which one was submitted using the value.

e.g.

if (isset($_GET['sub']) && $_GET['sub'] == 'Submit1'){

echo 'Submit1 was pressed';

} elseif (isset($_GET['sub']) && $_GET['sub'] == 'Submit2'){

echo 'Submit2 was pressed';

}
Aug 25 '08 #4
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="get">

That should be <?php echo $_SERVER['PHP_SELF'] ?of course, before
anyone comments... ;-)
Aug 25 '08 #5
..oO(The Natural Philosopher)
>jodleren wrote:
>Hi

It is late and I am tired. I cannot remember how to check which of my
buttons on the form was pressed. There are all submit's.

Like

echo "P=".$_POST['btn_post1']; // and eventually using isset()

But how was it it was?
Unless you use javascript with 'onclick' to set a hidden variable, I
don't think there is a way of working out which submit button was pressed.
Of course there is. Just give it a name and its value will be sent to
the server if you activate the button.

Micha
Aug 26 '08 #6
Michael Fesser wrote:
.oO(The Natural Philosopher)
>jodleren wrote:
>>Hi

It is late and I am tired. I cannot remember how to check which of my
buttons on the form was pressed. There are all submit's.

Like

echo "P=".$_POST['btn_post1']; // and eventually using isset()

But how was it it was?
Unless you use javascript with 'onclick' to set a hidden variable, I
don't think there is a way of working out which submit button was pressed.

Of course there is. Just give it a name and its value will be sent to
the server if you activate the button.
Oh? Never thought thought of naming a _submit_ button..

I gave up on em..they look too clunky..I always use javascript instead
on custom buttons..
Micha
Aug 26 '08 #7
On 25 Aug, 22:28, macca <ptmcna...@googlemail.comwrote:
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="get">

That should be <?php echo $_SERVER['PHP_SELF'] ?of course, before
anyone comments... * *;-)
Or even just:
<form action="" method="get">
Aug 26 '08 #8
..oO(The Natural Philosopher)
>Michael Fesser wrote:
>.oO(The Natural Philosopher)
>>Unless you use javascript with 'onclick' to set a hidden variable, I
don't think there is a way of working out which submit button was pressed.

Of course there is. Just give it a name and its value will be sent to
the server if you activate the button.
Oh? Never thought thought of naming a _submit_ button..
It's just another form control, nothing special.
>I gave up on em..they look too clunky..I always use javascript instead
on custom buttons..
No need for unreliable JS. <buttonand <input type="image"exist.

Micha
Aug 26 '08 #9

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

Similar topics

8
by: Harlin Seritt | last post by:
I have the following script. Two widgets call the same function. How can I tell inside of the called function which button called it?: def say_hello(): print 'hello!' print widget root =...
7
by: Tyron | last post by:
I need to know if the Left Button of the Mouse is clicked in the WM_NCMOUSEMOVE Notification but this Message doesnt contain the Mouse Button States as WM_MOUSEMOVE does. So how can I get them? ...
2
by: mwatcher | last post by:
Hi all, I am using .net 2.0. How can I get the current state of the mouse button (e.g.. Mouse Button Right is pressed). I'm not in a mouse event handler routine. What I wanna do is to check if...
9
by: phopman | last post by:
Hello! I am currently working on a project. And have been assigned to get up to speed quickly on php. And even though I love the language, it's not easy to get up to speed in like 2 seconds :-) ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.