0

Let me clear up what I'm doing. I am creating a plugin for WordPress and I have a settings page in that plugin for admin side. In that settings page I have some <img> tags and an array. I will require a shortcode to display those <img> tags in the posts and the shortcode will be used by end-users. Now here is my code:

<script type="text/javascript">
        itemOrder=new Array();
        $(document).ready(function() {
        $('#sortable').sortable();
        $(btn_ordering_over).click(function(){
        itemOrder = $('#sortable').sortable("toArray");
        document.getElementById("imgslideid1").src=document.getElementById(itemOrder[0]).src;
        document.getElementById("imgslideid2").src=document.getElementById(itemOrder[1]).src;
        document.getElementById("imgslideid3").src=document.getElementById(itemOrder[2]).src;
        document.getElementById("imgslideid4").src=document.getElementById(itemOrder[3]).src;
        w3.slideshow(".pics", 1100);        
        });
        <?php
        function slideshow_fun()
        { ?> 
        <script type="text/javascript">     
                alert(itemOrder[0]);          
        </script>
        <?php 
        }
        add_shortcode('slideshow_shortcode','slideshow_fun');
        ?>
        });
</script>

Now I need to access the array "itemOrder" in the slideshow_fun(). When I try to alert the element of "itemOrder" I get a message saying "undefined". Can anyone tell me what I should do? Thanks!

Bahman Parsa Manesh
  • 2,314
  • 3
  • 16
  • 32
Komal R
  • 387
  • 2
  • 16

0 Answers0