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

naming a created element

hi all!

when u create an element, how can u then give it a name so that if fo
example it is a form element it gets posted on submit. Also is it
possible to assgn an id too.

kind regards

marc

Aug 23 '06 #1
2 1030

libsfan01 wrote:
hi all!

when u create an element, how can u then give it a name so that if fo
example it is a form element it gets posted on submit. Also is it
possible to assgn an id too.
This isn't chat, please use proper punctuation when posting.

var newInput = document.createElement('input');
newInput.type = 'text';
newInput.name = 'personFirstName';
newInput.id = 'personFirstName';
If you assign a name, there isn't much point in also assigning an ID
unless you have a specific reason to. You can use ID instead of name
if you don't care about lack of support for version 4 browsers
(probably a little early to drop support just yet, but the day is
coming...).
--
Rob

Aug 23 '06 #2
RobG said the following on 8/23/2006 3:39 AM:
libsfan01 wrote:
>hi all!

when u create an element, how can u then give it a name so that if fo
example it is a form element it gets posted on submit. Also is it
possible to assgn an id too.

This isn't chat, please use proper punctuation when posting.

var newInput = document.createElement('input');
newInput.type = 'text';
newInput.name = 'personFirstName';
newInput.id = 'personFirstName';
You can use ID instead of name if you don't care about lack of
support for version 4 browsers
And if you don't need it submitted as a name/value pair to the server.
(probably a little early to drop
support just yet, but the day is coming...).
Give it a name, use the forms collection, and you don't ever have to
worry about it :)

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 23 '06 #3

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

Similar topics

4
by: VK | last post by:
09/30/03 Phil Powell posted his "Radio buttons do not appear checked" question. This question led to a long discussion about the naming rules applying to variables, objects, methods and properties...
6
by: clintonG | last post by:
Microsoft recommends CompanyName.TechnologyName and it all comes down to not breaking the inheritence model if I am not mistaken. VSN2003 however tells the compiler to use the name of the project...
0
by: Steve Jorgensen | last post by:
In a schema I've been working on recently, a convention I evolved was to use a consistent naming pattern such that, for instance, a Resident could appear in a ResidentSet, and could be referred to...
4
by: Mark Broadbent | last post by:
stupid question time again to most of you experts but this is something that continually bothers me. I am trying to get into the habit of naming variables and controls in an assembly as per...
3
by: clintonG | last post by:
Does the use of DTD, XML Schema and similar constructs adopt the use of C# naming conventions? If so how do I make the distinction of how to apply C# conventions with XML elements, attributes and...
8
by: Jason | last post by:
In my ASP.NET 1.1 solutions, I created several web projects and compiled them each into an assembly. The assembly names reflected the functionality of the feature (Membership.dll, Dues.dll, etc)....
0
by: paul.hester | last post by:
Hi all, I can't find a consistent naming convention rule for form elements and/or server controls with ASP .NET 2.0. What conventions do you generally use? For example, for a user name text...
114
by: Jonathan Wood | last post by:
I was just wondering what naming convention most of you use for class variables. Underscore, "m_" prefix, camel case, capitalized, etc? Has one style emerged as the most popular? Thanks for...
9
by: BillCo | last post by:
I'm coming from a MS Access background and so I'm very used to and comfortable with the hungarian (Leszynski et al) naming conventions. However, I'm getting started into my first SQL Server...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
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: 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
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...

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.