473,797 Members | 2,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create HIDDEN Input element using DOM

Hi All,

Can any one help me how to create a HIDDEN element using JavaScript
(DOM) dynamically
The following codes works fine with IE but not in Netscape

currentElement = document.create Element("input" );
currentElement. setAttribute("t ype", "hidden");
currentElement. setAttribute("n ame", "hiddenName ");
currentElement. setAttribute("i d", "hiddenName ");
currentElement. setAttribute("v alue", "14041978") ;
currentCell.app endChild(curren tElement);

and I'm appending 'currentCell' to a table cell which was also created
dynamically.

Can any one pull me out of this problem

Thanks in advance
Raghuram Banda

Jul 20 '05 #1
1 32155
Raghuram Banda wrote:
Hi All,

Can any one help me how to create a HIDDEN element using JavaScript
(DOM) dynamically
The following codes works fine with IE but not in Netscape

currentElement = document.create Element("input" );
currentElement. setAttribute("t ype", "hidden");
currentElement. setAttribute("n ame", "hiddenName ");
currentElement. setAttribute("i d", "hiddenName ");
currentElement. setAttribute("v alue", "14041978") ;
currentCell.app endChild(curren tElement);

and I'm appending 'currentCell' to a table cell which was also created
dynamically.

Can any one pull me out of this problem

Thanks in advance
Raghuram Banda


The reference to "currentCel l" probably isn't what you think it is, since
Gecko-based browsers include whitespace as text nodes in the DOM,
something like:

<tr id="myRow">
<td></td>

Could be accessed by document.getEle mentById('myRow ').firstChild in IE,
but in a Gecko-based browser (Mozilla, Safari, Firebird), all you'd get is
the new line text node which follows the <tr>.

Also, to prevent possible problems appending an input to a cell, and since
the thing you're adding is just a hidden input anyway, why not just append
it to either the body, or the form?

<body>
<form name="myForm">

....
document.body.a ppendChild(curr entElement);
.... or ...
document.forms['myForm'].appendChild(cu rrentElement);

--
| Grant Wagner <gw*****@agrico reunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2

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

Similar topics

2
4083
by: Nick | last post by:
Loop to create an array from a dynamic form. I'm having trouble with an application, and I'll try to explain it as clearly as possible: 1. I have a form with two fields, say Apples and Oranges. The user selects from a drop down menu, between 1-10 of each and clicks submit. The resulting page will display a NEW form, with rows and a list of fields for the amount of each items selected.
8
17307
by: Matt Herson | last post by:
I have been trying to find a way to use JavaScript to change the value of a hidden field on submit. I am already invoking a JavaScript to handle the validation on submit. The reason I need to change this field is some of the forms have two buttons on them, each needs to process the form differently. If I can change the value of the hidden field dynamically it will solve my issue as I can run each against a diffent cgi. Currently my...
7
6750
by: Eduard Dewolf | last post by:
Hi, Im have been changing my site to make it HTML 4.01 compliant As I should, I wrapped all INPUT tags in blocks I wrapped the not visible INPUT type HIDDEN tags in first PRE, later H6 tags to comply to HTML 4.01, but this changes my layout severly In the upper right corner of http://www.dewolf.net, one can cahnge the language of the site.
0
2735
by: yurps | last post by:
Hello here is my html, if you click the missing image in the first column on the left, the div is shown, when clicked again the div disappears...but the bottom border disappears as well...Is there anyway to stop this...??? <HTML> <HEAD> <title>Conform Inbox</title> <meta content="False" name="vs_snapToGrid">
6
3018
by: Omar | last post by:
Hi, In a JSP I have the next: .... codigo = "<select name='" + nombre + "'>\n<option selected value='default'>Escoge</option><option value='todos'>Todos</option>"; if (miRS != null) while (miRS.next()) {
10
3115
by: Mark McLellan | last post by:
Dear all Following the oft-repeated advice here and ciwas I have made my site nearly 4.01 strict (working on it). There are some items on which I would appreciate your advice: 1. Hidden fields http://www.zoo.co.uk/~mmenterprises/contact.htm I am using FormMail from Matt's Script Archive. The W3C validator objected to the hidden fields unless I put, say, P round them. That gave
13
2177
by: Geoff Cox | last post by:
Hello, How do I create a form without using document.write() which opens a new window? I imagine it has to do with using a <SPAN ID='idvalue' etc element and document.getElementById("idvalue").innerHTML but not clear how to do it... This is how I have done it at the moment ...
2
2214
by: Bill Steele | last post by:
I want to have a window pop up with a form. When the form is submitted, it needs to pass along the URL of the original window. If find on th web eight gazillion descriptions of how to pass data from one page to another via hidden fields, but not a word about how to pass that data a second time. I find that <SCRIPT LANGUAGE="JavaScript"><!-- document.write(document.referrer);
5
13428
by: bucchi | last post by:
Hi, I am doing the following in a javascript function: var hiddenElement = document.createElement("input"); hiddenElement .setAttribute("type", "hidden"); hiddenElement .setAttribute("name", ""hiddenElement"); hiddenElement .setAttribute("id", "hiddenElement"); hiddenElement .setAttribute("value", x.value);
0
9536
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,...
0
10468
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10021
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
9063
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...
0
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5458
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
4131
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
3748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2933
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.