www.tutorialspoint.com Forum Index
Register FAQMemberlistUsergroupsTutorials PointLog in
Reply to topic Page 1 of 1
Serialization problem
Author Message
Reply with quote
Post Serialization problem 
I have been working through the serialization tutorial and I want to do the same thing with images it would be perfect for what i am working on at the moment. I am new to javascript etc and would like to know if this is possible and if it is could someone tell me what I am doing wrong. It all works but the code in the button it doesn't give me any values just name[]=&name[]=&name[]=&name[]=
Code:

<html>
<head>
<title>Sorting Example</title>
<script src="javascripts/prototype.js" type="text/javascript"></script>
<script src="javascripts/scriptaculous.js" type="text/javascript"></script>
<script type="text/javascript">
   window.onload = function() {
       Sortable.create('imagelist',{tag:'div'});
   }
   
    function serialize(container, name){
      $('display').innerHTML =
      'Serialization of ' + $(container).id + ' is: <br/><pre>' +
      Sortable.serialize( container,{ name:name} ) + '</pre>';
   }

</script>

<style type="text/css">
   div { cursor: move; }
   img { border: 1px solid red; margin:5px; }
</style>
</head>
<body>

<p>Drag and drop list images to re-arrange them</p>

<div id="imagelist">
   <div><img src="one.jpg"/></div>
   <div><img src="two.jpg"/></div>
   <div><img src="three.jpg"/></div>
   <div><img src="four.jpg"/></div>
</div>
<p>Click following button to see serialized list which can be
passed to backend script, like PHP, AJAX or CGI</p>
<button type="button" value="Click Me"
           onclick="serialize('imagelist', 'name')"> Serialize
</button>
<div id="display" style="clear:both;padding-top:32px"></div>

</body>
</html>



_________________
Thanks
Robin
View user's profile Send private message
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum