473,663 Members | 2,726 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How To access form name if there's a form field named "name"

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>

When I do this, the alert shows "[object HTMLInputObject]" (in firefox)
or just "[object]" (in ie6) instead of the string "myform".

the problem is that I access the form element named "name" instead of
the forms name property.

Problem is this is a simplified example, in my real program there's
nothing I an do about the input elements name or else the cgi program
which receives the form values crashes, means i cannot change "<input
type="text" name="name"...> " to let's say <input type="text"
name="surname"> ".

Is there any solution to this problem? Thanks for any help. I suppose
there is some way of accessing the form's name property with the correct
notation.

Thanks for every help I can get
Jul 23 '05 #1
4 3957


Marc Elser wrote:

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>

When I do this, the alert shows "[object HTMLInputObject]" (in firefox)
or just "[object]" (in ie6) instead of the string "myform".

the problem is that I access the form element named "name" instead of
the forms name property.

Problem is this is a simplified example, in my real program there's
nothing I an do about the input elements name or else the cgi program
which receives the form values crashes, means i cannot change "<input
type="text" name="name"...> " to let's say <input type="text"
name="surname"> ".

Is there any solution to this problem? Thanks for any help. I suppose
there is some way of accessing the form's name property with the correct
notation.


With Mozilla I think it works to read
form.getAttribu te('name')
but IE messes things up when it comes to distinguishing between HTML
attributes and JavaScript properties.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Lee
Marc Elser said:

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>


Looking at the problem from a different direction,
are you sure you really need the form's name?
Is there any other way of identifying it that would work?

Jul 23 '05 #3
Martin Honnen wrote:

Give the text from element named "name" an id which is unique on the
page (maybe even the site). Like this: id="myName"

Now get the from element named "name" as an object like this:
var theName = document.getEle mentById("myNam e");

Now display the value in theName - you want it as an alert, therefore
like so:

alert(theName.v alue);

Works in MSIE and Netscape/Mozilla derivates.

That's it.

Chris
Marc Elser wrote:

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>

When I do this, the alert shows "[object HTMLInputObject]" (in
firefox) or just "[object]" (in ie6) instead of the string "myform".

the problem is that I access the form element named "name" instead of
the forms name property.

Problem is this is a simplified example, in my real program there's
nothing I an do about the input elements name or else the cgi program
which receives the form values crashes, means i cannot change "<input
type="text" name="name"...> " to let's say <input type="text"
name="surname"> ".

Is there any solution to this problem? Thanks for any help. I suppose
there is some way of accessing the form's name property with the
correct notation.

With Mozilla I think it works to read
form.getAttribu te('name')
but IE messes things up when it comes to distinguishing between HTML
attributes and JavaScript properties.

Jul 23 '05 #4
Hi All,

This is a sticky problem. Nevertheless, there should be an answer
somewhere.

I have a form table that changes dynamically as a result of selecting a
value in a Select. This can be seen at (I'll try html here) <a
href="http://members.optusne t.com.au/~malan2000/PCN/dealer.html"
target="_blank" >this url</a>

As you can see, the elements get created fine. The problem is that none
of the values of the created elements get parsed by my servlet.

This is the code that generates one checkbox:

var contentPlace = document.getEle mentById("conte ntPlace");
var cell = document.create Element("TD");
cell.id="conten tCell";
cell.colSpan= 9;
cell.align="cen ter";
var text1 = document.create TextNode("Auto" );
var input1 = document.create Element("Input" );
input1.name="au to";
input1.value="a uto";
input1.type="Ch eckBox";
contentPlace.ap pendChild(cell) ;
cell.appendChil d(text1);
cell.appendChil d(input1);

If I view Page Info in Mozilla all the elements of the form are there.

Any idea how to get this to work?

Thanks,

Chris

Jul 23 '05 #5

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

Similar topics

2
17748
by: John Davis | last post by:
I want to know what's the differences between Request.Form("Field Name") and Request.QueryString("Field Name") OR they function exactly the same, which is to return the value of the field?? Thanks, John
6
2301
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>
3
2688
by: Pavils Jurjans | last post by:
Hello, I have bumped upon this problem: I do some client-side form processing with JavaScript, and for this I loop over all the forms in the document. In order to identify them, I read their "name" property (which sources from "name" HTML attribue). The problem is, that if the form contains form control named "name", it overwrites the form name property. In fact, I'm quite surprised that it's so easy to spoil any of the form object...
13
8618
by: dhughey | last post by:
I am using <script type="text/javascript"> function setAction(frm){ act = ''; for(x=0;x<frm.se.length;x++){ if(frm.se.checked){ act = frm.se.value; } }
6
2297
by: Dick Watson | last post by:
I had a page that works when setup like this: === <form name="frmCalc" action=""> <script type="text/javascript"> function btnCalc_onclick(abc) { return "got here with " + abc; }
6
1996
by: karen987 | last post by:
I have a webpage called "topicview.asp" on a news website with ASP pages, it's a simple news publishing software. You add the news from the Admin section and all the details are stored in a database. This page shows all the categories filtered out, (10 to a page) but it doesn't show the NAME of the category anywhere on the page. How can i add the name of the category? In the database the title of the secction that stores the nm_tbl_cate...
1
7078
by: mark | last post by:
Forgive me if this seems like a stupid question but I need help... I'm trying to do a simple online form that emails me the results from a few fields. Here is the code: <form action="http://cm1web1/WebSurveyComponents/script/ processform.asp" method="post">
9
6962
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...
4
5519
by: KrazyKasper | last post by:
I'm a Novice User using Access 2003 Tables are via ODBC (i.e., cannot alter fields) I have a report that uses the field OrderRepName (text string) and is formatted as lastname, firstname, middleinitial (No prefixes or suffixes, etc.). Sometimes the field is blank and sometimes there is no middle initial. I found the following code on the Internet and it seems like it will work except I get an error message regarding Null values, and it...
0
8436
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8548
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
8634
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
7371
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
6186
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
4182
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...
1
2763
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
2
2000
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.