There is no return value to that function (so it will always return undefined), but I think you mean the value it sets for the element. If so, this should work out fine:
Code:
function serialize(s){
var serial = $.SortSerialize(s),
tmp = serial.hash.replace(/sort3\ [\]=/gi, '').replace(/&/g, ',');
document.getElementById('serial').value = tmp == '' || tmp == ' '? '0' : tmp;
};
Notes If I knew more about just what this was doing, I might try to set it up so that, if there were some type of input error, that would be caught and dealt with somehow and/or use a RegExp (instead of string equality) to test tmp. You had an undeclared global variable (serial) in your version. I've corrected that, but if it was already declared in the global scope and needs to remain like that for the rest of your code, use:
Code:
function serialize(s){
serial = $.SortSerialize(s);
var tmp = serial.hash.replace(/sort3\ [\]=/gi, '').replace(/&/g, ',');
document.getElementById('serial').value = tmp == '' || tmp == ' '? '0' : tmp;
};
Bookmarks