473,473 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to access an element inside innerHTML of a HTMLDivElement?

ssnaik84
149 New Member
Hello,

I have a HTMLDivElement. I checked its innerHTML property.
It has a hidden element (in innerHTML).

How I can access the hidden element?

For example, fbPartnerName is the HTMLDivElement

Expand|Select|Wrap|Line Numbers
  1. var fbPartnerName = document.getElementById("fbPartnerName");
  2. alert(fbPartnerName.innerHTML);
  3.  
it shows...

Expand|Select|Wrap|Line Numbers
  1. <input value="Talon Business Support Ltd - UK" name="fbPartnerName" id="fbPartnerName_hidden" type="hidden">
  2. <input active="false" pq="T" style="width: 420px;" class="ffb-input" autocomplete="off" id="fbPartnerName_input">
  3. <div class="ffb" style="top: 0px; left: 0px; display: none;" id="fbPartnerName_ctr">
  4.  
I want to access getElementById("fbPartnerName_hidden")
I tried ...
document.getElementById("fbPartnerName_hidden")

but it's not working..
Please guide me..

Thanks,
Swapnil
Dec 3 '09 #1
6 27034
RamananKalirajan
608 Contributor
You can easily access that particular element

Expand|Select|Wrap|Line Numbers
  1. var fbPartnerName = document.getElementById("fbPartnerName_hidden");
The fbPartnerName will have the div object using that u can get in two ways...

way 1

Expand|Select|Wrap|Line Numbers
  1. fbPartnerName.getElementById('fbPartnerName_hidden')
way2

Expand|Select|Wrap|Line Numbers
  1. var objArray =  fbPartnerName.getElementsByTagName("input");
  2. for(var i=0;i<=objArray.length;i++)
  3. {
  4.    if(objArray[i].type=="hidden")
  5.    {
  6.          var hiddenObj = objArra[i];
  7.    }
  8. }

Way 3:
If you have an id for that particular hidden variable. You can directly access
by

Expand|Select|Wrap|Line Numbers
  1. var hidObj = document.getElementById('fbPartnerName_hidden')
Thanks and Regards
Ramanan Kalirajan
Dec 4 '09 #2
Dormilich
8,658 Recognized Expert Moderator Expert
Expand|Select|Wrap|Line Numbers
  1. fbPartnerName.getElementById('fbPartnerName_hidden')
won’t work. getElementById() is only defined for the document interface.
Dec 4 '09 #3
RamananKalirajan
608 Contributor
@ Dormilich:
can't we use getElementById() for other objects other than document?

Thanks and Regards
Ramanan Kalirajan
Dec 4 '09 #4
Dormilich
8,658 Recognized Expert Moderator Expert
can't we use getElementById() for other objects other than document?
why? doesn’t make sense to use it for anything else than document.

PS. getElementsByTagName() (and the other getElementsBy* methods) do not return an array, but a NodeList/HTMLCollection.
Dec 4 '09 #5
Dormilich
8,658 Recognized Expert Moderator Expert
@ssnaik84

I had no problems with getElementById()
Dec 4 '09 #6
ssnaik84
149 New Member
Thanks friends
I resolved the problem... I refered HTMLDivElement document
Dec 4 '09 #7

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

Similar topics

1
by: Kenneth | last post by:
This is probably very simple question but how do you access elements inside the <div> tag? I need to access the value of a textfield inside a <div> tag. Thanks.
6
by: ste.paoletti | last post by:
hi, I have read that browsers support block element inside inline element but the css is not valid. Someone can tell me more about? What do you think? Thanks.
3
by: williamdiz | last post by:
hi all, I am trying to implement a page with different access rights inside that page for the users. ie inside the page there are different server controls. whenever user login to the system,...
2
by: wikkiwikkiwaa | last post by:
hello, i am trying to access controls inside my formview1 nested inside loginview1. you cannot access the formview1 unless you are properly logged in. for loginview1, that seems to be fairly...
3
by: rlueneberg | last post by:
I want to change the color of an "a" child element inside a table cell via javascript. Is there any way to do that? Ps: there is no id assigned to child elements. I would like to discover the child...
7
by: Amzul | last post by:
hello all, (congratulations for the new name admins) i have this anoyying issue that i cant resolve.. :( i am trying to open a small window (popup) with javascript. all i want in that...
5
by: SuneR | last post by:
Hi, I am having problems figuring out how to make Firefox behave, and output the HTML I want it to output. The thing I want done is actually quite simple. I have a <labeltag, and inside it, I...
2
by: MATTXtwo | last post by:
how to get/set element that inside of iframe from parent pages.. please give me tip.. my iframe define :name="ifrMenu" id="ifrMenu" the element inside of iframe that i need control :id="mnuLevel"
2
nathj
by: nathj | last post by:
Hi, I'm trying to develop what should be a simple jsp that reads an XML file, parses it and displays the content in a web page. Simple right? I have developed the XML and so any changes can be...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
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...
0
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.