Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Old 08-17-2008, 10:15 AM   #1 (permalink)
Senior Member
 
DragonEye's Avatar
 
Join Date: 10-13-03
Location: Belgium
Posts: 231
iTrader: 0 / 0%
Latest Blog:
None

DragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebody
Send a message via MSN to DragonEye
Accessing the body element with Javascript

Hi there,

I'm taking my first steps at AJAX and what I'm trying to do is make a box appear when user input in a form was incorrect.

I want to add that element (the UL element) as a child of the body tag but I can't access it.

How can I add an element in the body tag?

Thanks for the help

Matt.
DragonEye is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-17-2008, 12:54 PM   #2 (permalink)
Senior Member
 
DragonEye's Avatar
 
Join Date: 10-13-03
Location: Belgium
Posts: 231
iTrader: 0 / 0%
Latest Blog:
None

DragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebody
Send a message via MSN to DragonEye
I was a bit vague in my first post. This is the code I'm trying to execute:

Code:
var errorlist = document.createElement("UL"); errorlist.setAttribute("id","errormessages"); var targetelement = document.forms["adduserform"]; document.body.insertBefore(errorlist,targetelement);
In Iexplore i get a vague errormessage that the argument was not valid

In FF it says something about missing node... I don't get it

Matt.
DragonEye is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-18-2008, 01:32 AM   #3 (permalink)
v7n Mentor
 
Boogle's Avatar
 
Join Date: 09-03-07
Location: England
Posts: 646
iTrader: 0 / 0%
Latest Blog:
None

Boogle is just really niceBoogle is just really niceBoogle is just really niceBoogle is just really niceBoogle is just really niceBoogle is just really niceBoogle is just really niceBoogle is just really niceBoogle is just really niceBoogle is just really niceBoogle is just really nice
Hey, you are using the insertBefore method wrong, this is why your argument is invalid:

see here http://groups.google.com/group/comp....9ba423f5adf39c

Code:
var errorlist = document.createElement("UL"); errorlist.setAttribute("id","errormessages"); var targetelement = document.forms["adduserform"]; if (targetelement != null) { targetelement.parentNode.insertBefore(newA, refObj); }
You always need to call the DOM methods insertBefore and appendChild on
the parent node you want to append to or insert into.

HTH's

Boog's
__________________
Great new 'June' Javascript Framework
June Forums - Innovative JScripting

Price is what you pay... Value is what you get.
Boogle is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-18-2008, 01:57 AM   #4 (permalink)
v7n Mentor
 
Join Date: 07-24-06
Posts: 691
iTrader: 1 / 100%
Latest Blog:
None

nasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nicenasty.web is just really nice
The following code works perfectly for me:

Code:
var errorlist = document.createElement("UL"); errorlist.setAttribute("id","errormessages"); var targetelement = document.forms["adduserform"]; document.body.insertBefore(errorlist,targetelement); document.getElementById("errormessages").innerHTML = '<li>Test</'+'li>';
nasty.web is offline  
Add Post to del.icio.us
Reply With Quote
Old 08-18-2008, 09:28 AM   #5 (permalink)
Senior Member
 
DragonEye's Avatar
 
Join Date: 10-13-03
Location: Belgium
Posts: 231
iTrader: 0 / 0%
Latest Blog:
None

DragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebodyDragonEye is liked by somebody
Send a message via MSN to DragonEye
that fixed it, thanks
DragonEye is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing v7n John Scott Forum Lobby 2 02-29-2008 07:39 AM
Style within an XML element StupidScript Coding Forum 5 04-03-2007 05:22 PM
Trouble accessing Serverextreme serverextreme Tech Support Forum 0 02-13-2007 03:15 AM
Accessing a Blog from China Buskerdoo Blogging Forum 1 01-03-2007 09:59 PM
css help in element positioning. funguru Coding Forum 5 11-22-2006 08:37 PM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 09:32 AM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.