• Don’t know if anyone knows how this works, but I though, let’s give it a shot.

    I currently have the following code (javascript) to get a hash (for a plugin):

    function serialize(s)
    {
    	serial = $.SortSerialize(s);
    	alert(serial.hash);
    };

    Now this has the following output:
    sort3[]=links&sort3[]=images

    I want it to output:
    links,images

    How to do this?
    sort3[]= needs to be filtered
    & needs to replaced by ,

    I’ve tried things like:

    function serialize(s)
    {
            serial = $.SortSerialize(s);
            alert(serial.hash);
            var hash = serial.hash;
            var temp = hash.replace(new RegExp( "sort3\[\]=", "gi" ),'');

    and

    function serialize(s) {
        serial = $.SortSerialize(s);
        var hash = serial.hash;
        var temp = hash.replace(/sort3\[\]=/gi,'');
        alert(serial.hash);
    };

    But none worked 🙁 Hope you guys can help.

    Many thx,

    _Null

    ps 1: I am a noob so plz be gentle 🙂
    ps 2: For now I use the alert function to check/see the hash output, eventually I want to put it in a texfield/form to sent it to the db.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Don’t know if you’re still looking for a solution to this, but you should be able to get the desired output by doing something like:

    function serialize(s) {
        serial = $.SortSerialize(s);
        var hash = serial.hash;
        var temp = hash.replace(/sort3\[\]=/gi,'').replace(/\&/g,',');
        alert(temp);
    };

    and you can set the valud of a form field by swapping the alert call with something like:

    $('input[id=FORMFIELDID]').val(s)

    Oops, that’s wrong the last line should have read:

    $('input[id=FORMFIELDID]').val(temp);

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sortserialize and hash output problem’ is closed to new replies.