Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inner.html 1

Status
Not open for further replies.

nickdel

Programmer
May 11, 2006
367
GB
I have a div within a div which I'm trying to write a dynamic drop down which you will see from the code below. problem is I am getting an document.getElementById is null error but the div definately exists. Is it something to do with it being within another div?

Code:
for (var x = 1; x <= MaxNights; x++)
			   {
			   nights = nights + "<option name=NoNights value="+x+" />"+x
			   }

document.getElementById("nights").innerHTML= nights;
 
has nothing to do with that. when are you calling this code? are you calling it from a function or from inline javascript? if the latter, it's most likely because this code appears before the div itself.

either move the code into a function or place this code below your div.



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Show your HTML for the div you're trying to modify, too. Make sure you copy and paste rather than typing it in.

Lee
 
Its from within a function. The div is already written but is hidden. It is made visible before this part of the code is called.

here's the html also:

Code:
<select name="NoNights" onchange="GetPrice()">
     									<div id="nights"></div>
     								</select>
 
guys, I'm just being a complete tube! I can just dynamically populate the options, what was I thinking!!

if you still wish to answer would be interesting to see what I was doing wrong!!

Cheers

Nick
 
The div is already written but is hidden. It is made visible before this part of the code is called.

Are you going to show us ALL the relevant code, or make us ask for it piece by piece?

Lee
 
cLFlaVA, thanks, I'm really not having a good week. I did actually know that and should have saw it!!

You reply is appreciated once again (think thats the second this week!)

Nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top