473,659 Members | 3,631 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript DOM create input fields

69 New Member
Hi,

I use the following code to create a couple of input fields at run-time. It works fine in Firefox but it doesn't do anything in Internet Explorer and no errors are given. The DOM created elements are appended to a div called appendTo.

Expand|Select|Wrap|Line Numbers
  1. var className = "";
  2.  
  3. if( window.ActiveXObject )
  4.     className = "className";
  5. else
  6.     className = "class";
  7.  
  8. var row = document.createElement( "tr" );
  9.  
  10. var column = document.createElement( "td" );
  11. column.setAttribute( "height", "25" );
  12. column.setAttribute( "valign", "middle" );
  13. column.setAttribute( "width", "430" );
  14. column.setAttribute( className, "body_text_11_bold" );
  15.  
  16. var text = document.createTextNode( "Break out page link index" );
  17. column.appendChild( text );
  18. row.appendChild( column );
  19. document.getElementById( 'appendTo' ).appendChild( row );
  20.  
  21. row = document.createElement( "tr" );
  22.  
  23. column = document.createElement( "td" );
  24. column.setAttribute( "height", "25" );
  25. column.setAttribute( "valign", "middle" );
  26. column.setAttribute( "width", "430" );
  27.  
  28. var input = document.createElement( "input" );
  29. input.setAttribute( "id", "breakOutIndex" );
  30. input.setAttribute( "name", "breakOutIndex" );
  31. input.setAttribute( className, "formDrop" );
  32. input.setAttribute( "type", "text" );
  33.  
  34. column.appendChild( input );
  35. row.appendChild( column );
  36. document.getElementById( 'appendTo' ).appendChild( row );
  37.  
  38. row = document.createElement( "tr" );
  39.  
  40. column = document.createElement( "td" );
  41. column.setAttribute( "height", "25" );
  42. column.setAttribute( "valign", "middle" );
  43. column.setAttribute( "width", "430" );
  44. column.setAttribute( className, "body_text_11_bold" );
  45.  
  46. text = document.createTextNode( "Break out page menu text" );
  47.  
  48. column.appendChild( text );
  49. row.appendChild( column );
  50. document.getElementById( 'appendTo' ).appendChild( row );
  51.  
  52. row = document.createElement( "tr" );
  53.  
  54. column = document.createElement( "td" );
  55. column.setAttribute( "height", "25" );
  56. column.setAttribute( "valign", "middle" );
  57. column.setAttribute( "width", "430" );
  58.  
  59. input = document.createElement( "input" );
  60. input.setAttribute( "id", "breakOutMenu" );
  61. input.setAttribute( "name", "breakOutMenu" );
  62. input.setAttribute( className, "formDrop" );
  63. input.setAttribute( "type", "text" );
  64.  
  65. column.appendChild( input );
  66. row.appendChild( column );
  67. document.getElementById( 'appendTo' ).appendChild( row );
  68.  
Thanks,

Sean
Nov 21 '07 #1
1 3684
acoder
16,027 Recognized Expert Moderator MVP
Do you have a tbody tag? IE requires the tr elements to be appended to the tbody.
Nov 21 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
7064
by: Gowhera Hussain | last post by:
Use This for Learning Only .... Do Not Try To Act Smart HACKING WITH JAVASCRIPT Dr_aMado Sun, 11 Apr 2004 16:40:13 UTC This tutorial is an overview of how javascript can be used to bypass simple/advanced html forms and how it can be used to override cookie/session
5
2675
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one function to verify the name fields, age, email and gender. My question is: if I create a function for each field like the code below, what would be the best way to organize the functions and call them? Would I need one main function and place...
19
6871
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the page....Take a look at the JavaScript code and please let me know what each line is doing....I have been...
4
3500
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I click a button on a pop-up window the javascript for that button click does a 'button.form.submit'. On the Server side there is a Button click event for this button, but for some reason it no longer fires. It worked fine before and everything...
9
3962
by: Good Man | last post by:
Hi This is sort of a weird question, perhaps a bit off-topic... I am on the 'edit' screen of a web form, and I have a bunch of variables coming from a database that need to be placed into the form. In the past, I have been using PHP to pre-populate each field, something like <input type="text" id="firstName" value="<?= $first_name ?>" />
1
6876
by: kenny8787 | last post by:
Hi, can anyone help here? I have the following code generated from a database, I want to have javascript calculate the costs of the selected items using radio buttons, subtotal the costs and grandtotal the costs ready for the selected items to be inserted back to the database. I did something like this before with Checkboxes, but Radio button have to be named the same to maintain their groupings.
15
2280
by: Asterbing | last post by:
Already posted in comp.lang.javascript but not found any solution :-( -- Hi all, Don't know where to ask my question because the way to go is included in the possible answer itself by nature... You'll understand better below : Well, I have an HTML page containing a form in which an options group provides two ways to submit content of a file :
1
3363
by: anniefs | last post by:
hi help me i m so much stuck int he code and i have no time .... i used ASP VBscipt and javascript functions with MS database javascript function add records in MS DB by using ASP vbscript recordset varible when user click the save button then some values save in the database so i write javascript function to add the records... here is the code
3
9859
by: zac540 | last post by:
Hey everyone! First of all I'd like to say that I did my best to look for any other relevant posts. The best I found was this interesting thread.. http://bytes.com/forum/thread594982.html If it answered my question I am just to stupid to realize it I would like to apologize in advance. This is my very first attempt at using Javascript so any help at all is greatly appreciated. I read the W3Schools Tutorial on Javascript so that and some...
0
8428
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
8851
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
8748
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
8531
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
8628
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...
1
6181
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
5650
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();...
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1739
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.