473,386 Members | 1,674 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,386 software developers and data experts.

Extensible In-Line Help Code

Oralloy
988 Expert 512MB
Folks,

Sorry if this question is a little vague. I'm trying to improve on what looks to be a painful code methodology.

In short, I have a web application where I'm trying to embed help bits as part of the prompts for various form fields.

Basically I want to implement a "more/less" toggle, something like the code I have posted below.

Since the fields are built into the forms dynamically, I'm not sure how to identify HTML segments, except by using distinct identifiers. If there is a shorter, easier way, I'm all eyes. I am really getting tired of having to change names in six places each time I add help text to a field.

Anyway - the following is an example of what I have. Is there a better way to do this?

Expand|Select|Wrap|Line Numbers
  1. <script type='text/javascript'>
  2. {
  3.   function help_LL_Affected_Lifecycle_Phases()
  4.   {
  5.     var help = document.getElementById('help_LL_Affected_Lifecycle_Phases');
  6.     var tag = document.getElementById('tag_LL_Affected_Lifecycle_Phases');
  7.     if (help.style.display == 'none') {
  8.       help.style.display = '';
  9.       tag.innerHTML = 'less';
  10.     } else {
  11.       help.style.display='none';
  12.       tag.innerHTML = 'more';
  13.     }
  14.   }
  15. }
  16. </script>
  17. All project lifecycle phases affected by the lesson.&nbsp;&nbsp;<a href='#' onclick='help_LL_Affected_Lifecycle_Phases(); return false;'><strong id='tag_LL_Affected_Lifecycle_Phases'>more</strong></a>
  18. <div id='help_LL_Affected_Lifecycle_Phases' style='display:none'>
  19. <ul><li>Select all of the lifecycle phases, which are affected by this lesson.
  20. <li>Example: <strong>Preliminary Design</strong></ul>
  21. </div>

Thanks,
Oralloy
Sep 22 '10 #1

✓ answered by RamananKalirajan

You can use title attribute also. It is shown like a tool tip.

ex:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  <div>
  4.   This is the passage about the growing problem in human life. One of the major problem is <b><span style="cursor:pointer;" title="Complexity is a problem which affects the attitude of a person">complexity</span></b>
  5.  </div>
  6. </body>
  7. </html>
Thanks and Regards
Ramanan Kalirajan

2 996
RamananKalirajan
608 512MB
You can use title attribute also. It is shown like a tool tip.

ex:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3.  <div>
  4.   This is the passage about the growing problem in human life. One of the major problem is <b><span style="cursor:pointer;" title="Complexity is a problem which affects the attitude of a person">complexity</span></b>
  5.  </div>
  6. </body>
  7. </html>
Thanks and Regards
Ramanan Kalirajan
Sep 22 '10 #2
Oralloy
988 Expert 512MB
Ramanan,

This is what I've converged on:
Expand|Select|Wrap|Line Numbers
  1. <!--works-->
  2. All project lifecycle phases affected by the lesson.&nbsp;&nbsp;
  3. <div id='tagg_LL_Affected_Lifecycle_Phases'>(more)</div> 
  4. <div id='help_LL_Affected_Lifecycle_Phases'>
  5.  <ul><li>Select all of the lifecycle phases, which are affected by this lesson.
  6.  <li>Example: <strong>Preliminary Design</strong></ul>
  7. </div>
  8. <script type='text/javascript'> 
  9.  tagg = document.getElementById('tagg_LL_Affected_Lifecycle_Phases'); 
  10.  
  11.  tagg.help = document.getElementById('help_LL_Affected_Lifecycle_Phases'); 
  12.  tagg.help.style.display = 'none';
  13.  tagg.stat = 0;
  14.  tagg.style.color = 'blue';
  15.  tagg.style.fontWeight = 'bold';
  16.  
  17.  tagg.onclick = function() {
  18.   if (this.stat == 0) {
  19.    this.help.style.display = '';
  20.    this.innerHTML = '(less)';
  21.    this.stat = 1;
  22.   } else {
  23.    this.help.style.display='none';
  24.    this.innerHTML = '(more)';
  25.    this.stat = 0;
  26.   }
  27.   return false;
  28.  }
  29.  
  30.  tagg.onmouseover = function() {
  31.   this.style.cursor='help';
  32.  }
  33. </script>
Have you got any addititional suggestions on how to make it cleaner?
Sep 22 '10 #3

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

Similar topics

0
by: jerrygarciuh | last post by:
I was wondering if anyone had any advice or recommendations on finding a stable, extensible eCom cart/ fullfillment system using mySQL and PHP (or Perl)? My client is preparing to get online...
4
by: Karen Sundquist | last post by:
I have a client who wants to build a database with a user extensible schema. The client wants to model an entity with about 100 numeric attributes. As time goes on, more numeric attributes will...
0
by: Sony Antony | last post by:
We have an xml/java/W3C schema/jaxb based application. I would like to define some elements that are extensible. In particular the schema has an element defined as 'exception'. This has an integer...
1
by: Bren | last post by:
I'm hoping somebody can help me with the following problem. I'm hoping it's not insurmountable. Here's a basic structure: class EventTarget { public: EventTarget(); virtual ~EventTarget();
9
by: Maury Merkin | last post by:
Hi, I manage a couple of Web sites which, occasionally, use foreign (i.e. non-English, since English is the language of these sites) words. My elementary school teacher told me that foreign...
2
by: Hazz | last post by:
If in an interview next week I was told to Design and Develop Extensible Web Application Frameworks using Microsoft .NET technologies. How do I break that question down? My first temptation...
5
by: Peter Gummer | last post by:
Has anyone tried Extensible C# (XC#) from ResolveCorp (<http://www.resolvecorp.com/>)? It looks good, it’s been around for a few years, but there seems to be almost no mention of it on the web....
2
by: Lucas Tam | last post by:
Any ideas on how to build a web application that can support modules easily? Something like DotNetNuke... any other alternative? What do you guys used to build an extensible web app? I was...
5
by: Nice | last post by:
seems XML is used in SOAP for transfer information and used as config files most time in dotnet. Where XML will be used in real project development?
1
by: Sergei Shelukhin | last post by:
Hi. We have a resource assembly that is separate and is used by a class library assembly, a web app, web service set (all in separate projects). Windows app is also potentially possible. First...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.