Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Oct 2002
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Sortserialize and hash output problem

    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:

    Code:
    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:

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

    Code:
    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.

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Code:
    alert(serial.replace(/sort3\[\]=/gi, '').replace(/&/g, ','));
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #3
    New Coder
    Join Date
    Oct 2002
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by shyam View Post
    Code:
    alert(serial.replace(/sort3\[\]=/gi, '').replace(/&/g, ','));
    Thx, but this results in a non working alert.

    Eventually I want this output filtered in a text field so I can upload it to a db. Perhaps it´s easier to filter it as a string? Maybe you guys can give me examples of how to do that? (since the alert doesn't work/causes issues?)

    Thanks

  • #4
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    did u try this?
    Code:
    alert(serial.hash.replace(/sort3\[\]=/gi, '').replace(/&/g, ','));
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow

  • #5
    New Coder
    Join Date
    Oct 2002
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by shyam View Post
    did u try this?
    Code:
    alert(serial.hash.replace(/sort3\[\]=/gi, '').replace(/&/g, ','));
    Excelent, that worked . Thank you very much!

    Next stop, getting the alert into a input field (onclick put a value into a textbox/inputfield)

  • #6
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Null View Post
    Excelent, that worked . Thank you very much!

    Next stop, getting the alert into a input field (onclick put a value into a textbox/inputfield)
    In this thread I understand that you want to set the value of the input to what you have in alert box but in onclick put a value into a textbox/inputfield) I answer to the question "how to retrive the value from the input?".

    So, if you want to set/retrive the value of the input to something you can do:

    Identify the object with name="serial"
    Code:
    var s = document.getEelemtById('serial');
    set the value to what you need:
    Code:
    s.value = serial.hash.replace(/sort3\[\]=/gi, '').replace(/&/g, ',');
    retrive the value from input and for example use into an alert box:
    Code:
    alert(s.value)
    maybe this http://www.javascriptkit.com/ could help you more

    best regards
    Last edited by oesxyl; 12-12-2007 at 03:50 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •