Skip to main content
March 6, 2009
Question

Question on <span>

  • March 6, 2009
  • 3 replies
  • 457 views
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.
    This topic has been closed for replies.

    3 replies

    Inspiring
    March 6, 2009
    <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.
    March 6, 2009
    I have to show or hide only a part of page....Dan, can you provide a small example?
    Inspiring
    March 6, 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.