Serialization problem

General discussion on technical and managerial topics
no avatar
Posts: 1
Joined: Thu Sep 18, 2008 12:09 am

Serialization problem

by robinrl » Thu Sep 18, 2008 12:18 am

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: Select all
<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() {
    function serialize(container, name){
      $('display').innerHTML =
      'Serialization of ' + $(container).id + ' is: <br/><pre>' +
      Sortable.serialize( container,{ name:name} ) + '</pre>';


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

<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>
<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
<div id="display" style="clear:both;padding-top:32px"></div>


Return to General Discussion