Html to json

gerarJson: function(idTag) { var json = "{"; $('#' + idTag + ' input, ' + '#' + idTag + ' select').each(function() { //this line can be removed, it's to ignore a jquery plugin if(!$(this).hasClass("selectivity-search-input") && !$(this).hasClass("selectivity-single-select-input")) { if(!$(this).prop('disabled')) { if($(this).is(':radio')) { if($(this).prop('checked') == true) json += ('"' + this.name + '":' + '"' + this.value + '",') } else if($(this).is('select')) { json += ('"' + this.name + '":' + '"' + $(this).find('option:selected').val() + '",') } else json += ('"' + this.name + '":' + ((this.value) ? '"' + this.value.replace('-', '') + '"' : null) + ',') } } }); json = json.substring(0, json.length-1) + '}'; return json; },

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.