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?
Thanks,
Oralloy
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?
Code:
<script type='text/javascript'>
{
function help_LL_Affected_Lifecycle_Phases()
{
var help = document.getElementById('help_LL_Affected_Lifecycle_Phases');
var tag = document.getElementById('tag_LL_Affected_Lifecycle_Phases');
if (help.style.display == 'none') {
help.style.display = '';
tag.innerHTML = 'less';
} else {
help.style.display='none';
tag.innerHTML = 'more';
}
}
}
</script>
All project lifecycle phases affected by the lesson. <a href='#' onclick='help_LL_Affected_Lifecycle_Phases(); return false;'><strong id='tag_LL_Affected_Lifecycle_Phases'>more</strong></a>
<div id='help_LL_Affected_Lifecycle_Phases' style='display:none'>
<ul><li>Select all of the lifecycle phases, which are affected by this lesson.
<li>Example: <strong>Preliminary Design</strong></ul>
</div>
Thanks,
Oralloy
Comment