473,320 Members | 1,810 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,320 software developers and data experts.

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 41141
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
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
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...
6
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...
4
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">...
2
by: Jeff Baker | last post by:
How does one post to an ASPX page using the WebClient when the form name is required?
2
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*...
4
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...
3
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,...
9
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...
3
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.