473,387 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Access <div> element from another template.using JS

Hi,
I am developing a website . The home page contains 10 different html templates.
What I need to do is that i want to access a div tag from a template which is defined in another html template. I tried

document.getElementById('d').innerHTML="some text";

but it is showing null.

Is there any way to define <div> as global so it is accessible from any other html template.

Kindly help me on this.
Oct 10 '08 #1
3 2815
acoder
16,027 Expert Mod 8TB
Are you using iframes or frames to include the HTML pages?

If so, you need to access the (i)frame first and then access the elements within.
Oct 10 '08 #2
Are you using iframes or frames to include the HTML pages?

If so, you need to access the (i)frame first and then access the elements within.

I am using neither of them. My final html page consists of different templates(html pages). I am using symfony framweork for development. The html code is written in symfony templates & then the templates are included into a final template which displays an html page.
Oct 10 '08 #3
gits
5,390 Expert Mod 4TB
the javascript code runs when the page is rendered at the client - so to be sure that the div with the id 'd' (the one you use) is available for the dom-method then you should ensure that the execution of the javascript code is triggered when the page is fully loaded and the dom is ready to use - you might use the documents onload event for this purpose ...

kind regards
Oct 10 '08 #4

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

Similar topics

13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
14
by: Charlie T | last post by:
Hello, is there any way to get this to work? myID.innerHTML = "Hello" <DIV id="myID"></DIV> <DIV id="myID"></DIV>
14
by: Simon Wigzell | last post by:
I want to display HTML text inside a div and have the page open scrolled to the bottom. (My div has overflow:auto so that it appears with scroll bars) I have found this that works on a textarea:...
4
by: joe | last post by:
Hi, I defined: <div id="abc"> </div> in my .html file, after an Ajax query my weberserver sends: <script language="JavaScript"> alert('Hello World!"); </script>
28
by: Kent Feiler | last post by:
1. Here's some html from a W3C recommendations page. <P>aaaaaaaaa<DIV>bbbbbbbbb</DIV><DIV>cccccccc<P>dddddddd</DIV> 2.Although I didn't think it would make any difference, I tried it with the...
5
by: chakradhari.ashish | last post by:
Does anybody know how can I load an html page inside a <div</div> where the content gets update on the onclick even of anchor <a href=> </a>? I googled around and followed some links pointing me...
10
by: Summercoolness | last post by:
so i am starting to use more of <br /and <div style="clear: both" / which is the XHTML style... now, won't those actually confuse the old browsers? for example, will the old browser treat the...
0
by: msch-prv | last post by:
How to maintain the display state of a <divelement? Is there a simple way to maintain the display state of a <div> element? On my page, a div block can be hidden/shown by js function...
2
by: paul | last post by:
I have a JS function to change the width of a <divthat works great in Firefox, but not at all in IE7. In IE an error message occurs: Line: 92 Char: 5 Error: Invalid Argument Code: 0 Firefox...
8
prino
by: prino | last post by:
Hi all, I've written code (in REXX) that takes files in legacy languages (PL/I, COBOL, z/OS assembler, etc) and converts them into HTML in a format similar to what's displayed in the z/OS ISPF...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.