473,730 Members | 4,274 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get form name / id ??

I have a form

<form name="jim" id="jim" .......... >
.........
</form>

How do I get either the name or id from the form in PHP ?
--

Rick

Digital Printing
www.intelligence-direct.com - 01270 215550
Jul 17 '05 #1
7 41207
Rick wrote:
I have a form

<form name="jim" id="jim" .......... >
........
</form>

How do I get either the name or id from the form in PHP ?


You don't, unless you add it as a hidden input or a get-variable.

<input type="hidden" name="formname" value="myform">

And just grab that from $_POST['formname'] in your script.
Roy W. Andersen
--
ra at broadpark dot no / http://roy.netgoth.org/

"Hey! What kind of party is this? There's no booze
and only one hooker!" - Bender, Futurama
Jul 17 '05 #2
*** Rick wrote/escribió (Thu, 13 Jan 2005 12:48:44 +0000):
<form name="jim" id="jim" .......... >
........
</form>

How do I get either the name or id from the form in PHP ?


The names are the keys in the $_GET or $_POST array.

foreach($_POST as $key => $value){
echo "<li>$key: $value</li>";
}

--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Jul 17 '05 #3
Alvaro G Vicario wrote:
*** Rick wrote/escribió (Thu, 13 Jan 2005 12:48:44 +0000):
<form name="jim" id="jim" .......... >
........
</form>

How do I get either the name or id from the form in PHP ?


The names are the keys in the $_GET or $_POST array.

foreach($_POST as $key => $value){
echo "<li>$key: $value</li>";
}


Thats only for inputs contained within a form

--

Rick

Digital Printing
www.intelligence-direct.com - 01270 215550
Jul 17 '05 #4
Roy W. Andersen wrote:
Rick wrote:
I have a form

<form name="jim" id="jim" .......... >
........
</form>

How do I get either the name or id from the form in PHP ?


You don't, unless you add it as a hidden input or a get-variable.

<input type="hidden" name="formname" value="myform">

And just grab that from $_POST['formname'] in your script.


Bugger, thats what I am doing at the moment, was hoping there was a better
way :/

--

Rick

Digital Printing
www.intelligence-direct.com - 01270 215550
Jul 17 '05 #5
Rick wrote:
Roy W. Andersen wrote:
<input type="hidden" name="formname" value="myform">

And just grab that from $_POST['formname'] in your script.


Bugger, thats what I am doing at the moment, was hoping there was a better
way :/


Sending it as a POST with the rest of the form is pretty straight
forward and simple. If you're doing a foreach() loop on the $_POST array
on the serverside and don't want to do whatever you do to the form data
with that field, just issue an if/else or switch-statement to filter it
out. Either that, or you can start by grabbing the $_POST['formname']
followed by an unset($_POST['formname']) to avoid it carrying into the
code you got further down :)
Roy W. Andersen
--
ra at broadpark dot no / http://roy.netgoth.org/

"Hey! What kind of party is this? There's no booze
and only one hooker!" - Bender, Futurama
Jul 17 '05 #6
*** Rick wrote/escribió (Thu, 13 Jan 2005 13:00:55 +0000):
Thats only for inputs contained within a form


You are right, I misunderstood you. The answer is: you cannot. That info is
not sent to the server. Just add an extra hidden field.

--
-- Álvaro G. Vicario - Burgos, Spain
-- Thank you for not e-mailing me your questions
--
Jul 17 '05 #7
.oO(Rick)
Roy W. Andersen wrote:
You don't, unless you add it as a hidden input or a get-variable.

<input type="hidden" name="formname" value="myform">

And just grab that from $_POST['formname'] in your script.


Bugger, thats what I am doing at the moment, was hoping there was a better
way :/


Nope. The name attribute for the form element is just there for
backwards compatibility (according to the spec, personally I've never
used it), so it's rather useless and not submitted to the server at all.

Micha
Jul 17 '05 #8

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

Similar topics

3
1546
by: Scott Navarre | last post by:
Hello, I have a javascript function that I want to read the name of the form which is calling it. Here is my HTML: <HTML> <HEAD> <SCRIPT LANGUAGE="JavaScript">
4
1511
by: Edward Lim | last post by:
Hi guys, is it possible to retrieve the name or the id of a form in an ASP.Net page? In the code behind inside the page class, I would like to be able to reference to that "form object" and to retrieve its name or id. is that at all possible? Cheers
6
2316
by: Java script Dude | last post by:
We just discovered another IE bug. When an html form contains an element with a name of `name` IE's internal index screws up the .name property of the containing form to point to the bad element object instead of containing the string name property of the form. Here is the simplified test case: <html>
4
3966
by: Marc Elser | last post by:
Hi Everybody, Can someone please tell me how to access the form name if there's a form field named "name", for example: <form name="myform"> <input type="text" name="name" value="Marc"> <input type="button" onClick="alert(this.form.name);"> </form>
2
2474
by: Jeff Baker | last post by:
How does one post to an ASPX page using the WebClient when the form name is required?
2
1782
by: ej | last post by:
I'm not seeing how to get at the 'name' attribute of an HTML <form> element. form = cgi.FieldStorage() gives you a dictionary-like object that has keys for the various named elements *within* the form... I could easily replicate the form name in a hidden field, but there ought to be some way to get directly at the form name but I'm just not seeing it. I looked in the os.environ() - don't see it there.
4
5502
by: ashore | last post by:
Folks, the snippet below errors out on both FF and IE, with FF's error console complaining "this.form has no properties", while a reference to "document.forms.name" works correctly. <form name='whatever1' method = "post" action="javascript:alert(this.form.name);"> <input type="button" value="click" onClick = "this.form.submit();"/> </form> Any ideas welcome,
3
1755
by: scripteaze | last post by:
posting to a form with no form name or it's just that i cant find the form name. can anyone explain how to either post to a form with no name or, find the name of the form..here my current output, but i dont see a form name, also, there is only 1 form on the page <POST https://somesite.com/login.html application/x-www-form- urlencoded <TextControl(username=)> <PasswordControl(password=)>
9
6969
by: scripteaze | last post by:
Im using mechanize method for retrieving the form so that i may log into it. I need to find a way to get the form name. Its not listed anywhere in the html source.The reason i need to do this is because im tryin not to use the for loop below. Someone told me that the form name should be listed in the 'print form' portion of the codes output. I dont believe the form name is listed there also. Any ideas/help would be great. Thank you in...
3
2678
by: franc sutherland | last post by:
Hello, I have a report which I filter using the me.filter command in the OnOpen event. Me.Filter = "OrderID=" & Forms!variable_form_name! Me.FilterOn = True I want to be able to open that report, filtered, from different forms. How do I carry the name of the current form into the
0
9301
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9229
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9176
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8184
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6725
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4543
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4801
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3257
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.