Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Question on <span>

Guest
Mar 05, 2009 Mar 05, 2009
Hello,

I have a question on using span for hiding and showing certain contents. I have a drop down and when I select one value, the page includes a file within a span tag, something like
<span id="show"
<cfinclude template="file.cfm">
</span>

right now I am using
<cfif isdefined("form.dropdown") and form.dropdown eq '1'>
<span id="show">
<cfinclude template="file.cfm">
</span>
</cfif>
I know this can be done using javascript like document.getelementbyid.style = "none".

Can anyone suggest which is the best way to do or which is the correct way to do this?

Thanks.
435
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 05, 2009 Mar 05, 2009
If you mean that you want the contents of the form page to change based on a drop down selection, I recently did just that. I used div instead of span, which may or may not be relevent. The general idea was:

1. use cfsavecontent to generate coldfusion variables.
2. use toScript() to bring those variables into javascript.
3. Had js code to assign those variables to my div in the select's onchange event.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 06, 2009 Mar 06, 2009
I have to show or hide only a part of page....Dan, can you provide a small example?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 06, 2009 Mar 06, 2009
LATEST
<cfsavecontent variable="x">
code
</cfsavecontent>
<script>
function toggle (choice) {
<cfoutput>
var #toScript(x, "js_something")#;
</cfoutput>

if (choice == "va1"){
document.getElementById('abc').innerHTML = js_something;
}

else {
document.getElementById('abc').innerHTML = "";
}
return true;
}

<div id="abc"></div>

You can do the form part yourself.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources