Programming Tools
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingProgramming Tools

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 26th, 2002, 08:00 PM
evildoppler evildoppler is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 3 evildoppler User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to evildoppler
Cool DHTML/DOM appendChild() problem

Hey guys!

I've been hunting a bit of information in my quest to finally learn DHTML and to utilise the DOM more effectively.

Anyways, got into a bit of a problem that I don't seem to be able to "study" my way out of.

The problem is simple, annoying but simple.

I'm creating an element - in this case an input field and appends it to a <form> so that the <form> won't ignore the input field.

So what happens is that it will - depending on browser used - make the input field appear at the top of the form (before any other input element) or at the bottom (after any other input element).

The problem I have is that i need this input field to appear at a certain point - within a specific <div>.

Now, normally I'd just have appended the input field to the div BUT in doing that i'll loose the input field from the form during submission.

To give you a better understanding of what i'm attempting here.

Code:
function AddInputField(foo) {

  if (ns6) {
	ElementPresent = (document.getElementById('newInputField'))? true:false;
  }
  else if (ie4) {
	ElementPresent = (document.all["newInputField"])? true:false;
  }
  else if (ns4) {
	ElementPresent = (document.layers["newInputField"])? true:false;
  }

if (!ElementPresent) {
 var inputElement = document.createElement("input");
 inputElement.setAttribute("id","newInputField");
 inputElement.setAttribute("name","newInputField");
 
 var targetDiv = document.createElement("div");
 targetDiv.setAttribute("id","targetDiv");
	 		 
	 if (foo == "other") {
	 	if (ie4) {
		  document.all["select"].appendChild(targetDiv);
		  document.all["submitForm"].appendChild(inputElement);	
		}
		else if (ns4) {
		  document.layers["select"].appendChild(targetDiv);
		  document.layers["submitForm"].appendChild(inputElement);
		}	 
		else if (ns6) {
		document.getElementById('select').appendChild(targ  etDiv);
		document.getElementById('submitForm').appendChild(  inputElement);
		}	
	 }
 }
 else {
 	if (foo != "other") {	
	   if (ie4) {
		 var node1 = document.all["submitForm"];
	     var node2 = document.all["newInputField"];
         var exe = node1.removeChild(node2);
		}
		else if (ns4) {
		 var node1 = document.layers["submitForm"];
		 var node2 = document.layers["newInputField"];
		 var exe = node1.removeChild(node2);
		}	 
		else if (ns6) {
		  var node1 = document.getElementById('submitForm');
		  var node2 = document.getElementById('newInputField');
		  var exe = node1.removeChild(node2);
		}
	 }
   }
}


So, if anybody could give me a hand then it'd be rather appreciated.

Cheers and thanks - Happy Christmas and Merry New Year

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingProgramming Tools > DHTML/DOM appendChild() problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT