473,652 Members | 2,979 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How would I add innerHTML to my expandable content script?

1 New Member
Hello, I found a script for innerHTML, which has a basic expand / collapse function. However, when it comes to table cells … it craps out. I know some form of toggle function needs to be added, something the lines of this

Expand|Select|Wrap|Line Numbers
  1. function toggle(id) { var tr = document.getElementById(id);
  2. if (tr==null) { return; } var bExpand =  tr.style.display == '';
  3. tr.style.display = (bExpand ? 'none' : ''); }
  4. function Toggle_h1() { toggle('row1'); toggle('row2'); }
  5. function Toggle_h2() { toggle('row3'); toggle('row4'); }
  6.  
However, I cannot make the two codes cohere. Here is the innerHTML script

Expand|Select|Wrap|Line Numbers
  1. function toggle(eina,id,show,hide) {
  2. var tvo = document.getElementById( id );
  3. if( eina.innerHTML == hide ) { eina.innerHTML = show;
  4. tvo.style.display = 'none'; } else { eina.innerHTML = hide;
  5. tvo.style.display = 'block'; } }
  6.  
I've tried quite a bit to make them work, however, I cannot make it work. Is it possible to add the toggle table cell function to the innerHTML, or vice-versa
Nov 29 '09 #1
1 2116
Dormilich
8,658 Recognized Expert Moderator Expert
the CSS property display (line #2) must have a value ('' is invalid). (I think it has to be "table-row")
Nov 29 '09 #2

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

Similar topics

7
3471
by: KK | last post by:
Please help! I am currently experiencing a bug in Safari v125.9. When I modify the value of form input box and then get the innerHTML property of the surrounding div object - I am returned the original form value not the changed value! Has anyone else encountered this? Cheers.
4
6032
by: Doug | last post by:
Hi - I'm looking to code some javascript that has an event handler tied to an image ("a down arrow") that will expand code that was hidden on the page load. It's pretty simple, I have an accessories html table that I want to load in the html but hide to save page real estate until you click the "down arrow" image. I know I've seen stuff like this before, can anyone point me to an example of this or give me an idea of how to code it? ...
1
2050
by: Paul | last post by:
Here is my current code: ------------ <script runat=Server> void Page_Load(object sender, EventArgs e){ if (!IsPostBack){ myDiv.InnerHtml = "Original Content"; } //On Postback, should equal "Original Content and New Content" string strContent = myDiv.InnerHtml; }
4
10487
by: SimonV | last post by:
Hmm, I let the user add more input fields as needed. But I have a strange problem with ff (and other mozillas) When I add a field in ff, the others lost their content... In IE the content stays Is there a work-around for this? this a piece of code to check this out: <html> <head>
17
34701
by: PJ | last post by:
Greetings... I have stumbled upon a small problem. I use Ajax to retrieve part of a page I need to update. I update a DIV element with the HTML contents I get from another page. It works fine. However the HTML have a SCRIPT tag that the browser should process, but
7
15417
by: bobd314 | last post by:
Currently, I am having a problem replacing the value of a input box with something else using the innerHTML thing. Right now I have something going <script type="text/javascript"><!-- function changeText(newText){ document.getElementById("WHATEVER").innerHTML=newText } //--> </script>
1
2192
by: huzheng001 | last post by:
I have develop a on-line dictionary website, http://www.stardict.org I meet a problem: Here is two lines of js codes: document.getElementById("wordlist").innerHTML = ""; document.getElementById("definition").innerHTML = "line1<br>line2"; The corresponding html codes are: <table width="100%"> <tr> <td width="25%" valign="top"><div id="wordlist" width="100%" style=' overflow-y:auto; height:352px;'></div></td>
2
2725
by: ars | last post by:
hi everyone i'm using some regular expression to paging, it work's fine in IE but not in Firefox i removed every thing to detect problem but i Can't , the only thing i got, is the innerHtml doent work as it should here is my page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type"...
8
3213
by: Pratik Patel | last post by:
Hello, I used innerHTML to assign HTML content. but in my HTML page content have also some javascript function and it will run when page load. bu when HTML code assgin thru innerHTML then this javascript is not working. e.g. html content:
0
8367
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8703
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8589
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5619
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.