Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Darren Wilson 218 posts 556 karma points
    Mar 07, 2012 @ 13:11
    Darren Wilson
    0

    Adding content items to javascript

    Hi Folks,

    Apologies if this has been asked before.

    I have a small javascript item that when a dropdownn is selected the contents of a DIV is changed depending on what item is picked.

    I would like the chosen DIVs to feature Content Items - so far I;ve got the following JS:

    <script type="text/javascript">
        function change()
           {
           switch (document.getElementById("select").value)
           {
            case "1":
            document.getElementById("change").innerHTML = '<umbraco:Item field="title1" runat="server"></umbraco:Item>'
            break;
            case "2":
            document.getElementById("change").innerHTML = "<umbraco:Item field="title2" runat="server"></umbraco:Item>";
            break;

    </script>


    This works perfectly when it's just html text but doesn't display anything when the content items are added - am I doing something wrong? Any help will be great appreciated.

    Thanks in advance

    Darren

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies