/* function getUrlParameters(parameter, staticURL, decode) function sxRoundNumber(rnum, rlength) function sxDateDiff(date1, date2) function FormatNumberBy3(num) function CurrencyFormatted(amount) function ReplaceAll(Source, stringToFind, stringToReplace) function ReplaceAll2(Source, stringToFind, stringToReplace) usa regexp per la ricerca function numerico(num) function numericov(num) function esiste(str) function isset () function PostUrl(URLtarget, valoreParametro) function PostUrlEx(URLtarget, valoreParametro) function parseQuery(qstr) function ApriFinestra(mydiv,larghezza,altezza) function togliFinestra() function datefromYYYYMMAA(s) function HideTooltip() depregate function DateAAAAMMGGtostr(dataIn) function DatetostrAAAAMMGG(dataIn) function strToDate(dataIn) function Datetostr(dataIn) function strAAAAMMGGToDate(dataIn) function sxDateDiff2(date1, date2) function searchStringInArray (str, strArray) { function N2S(num,dim) function Mydate() function isDate (x) function isChecked(id) // combobox selezionato function setChecked(id,valore) // combobox selezionato valore true/false function setSelected(id,valore) // select set opzion value selezionato valore function isVisible(id) function setVisible(id,valore) function myHide(str) function N2S(num,dim) function Arr_Remove(arr, item) function dateFromISO(s) function nvl(oggetto,valoreDefault){ function isEmpty(s) function dataUguale(data1, data2) function inObjArray(oggetto, arrayOggetti) function cloneDR(o) function goToByScroll(id) function myTime() function showError(campo,err) function sortByKey(array, key,key2) // sort di un array con una o due campi function sortByKeyNum(array, key) { function DataFromCF(cf) { function MFFromCF(cf) { function newDate() function deleteAllRow(tableID) //cancella tutte le riche della tabella */ function getUrlParameters(parameter, staticURL, decode){ /* Function: getUrlParameters Description: Get the value of URL parameters either from current URL or static URL Author: Tirumal URL: www.code-tricks.com uso Argument Description parameter Name of the parameter to get. staticURL Provide Static URL as string to get the parameters decode Provide boolean true or false to decode URL component, for example provide true for converting �Hello%20World� to �Hello World� */ var currLocation = (staticURL.length)? staticURL : window.location.search, parArr = currLocation.split("?")[1].split("&"), returnBool = true; for(var i = 0; i < parArr.length; i++){ parr = parArr[i].split("="); if(parr[0] == parameter){ return (decode) ? decodeURIComponent(parr[1]) : parr[1]; returnBool = true; }else{ returnBool = false; } } if(!returnBool) return ""; } ////////////////////////////////////////////////////////////// function sxRoundNumber(rnum, rlength) { // Arguments: numero da arrotondare , numero di decimali var newnumber = Math.round(rnum*Math.pow(10,rlength)+(1/Math.pow(10,rlength+3)))/Math.pow(10,rlength); return newnumber; } function sxDateDiff(date1, date2) { dat1 = Date.UTC(date1.getFullYear(),date1.getMonth(), date1.getDate()) ; //_saldo_2 dat2 = Date.UTC(date2.getFullYear(),date2.getMonth(), date2.getDate()) ;//_saldo_2 //_saldo_2 var giorni=parseInt((date1.getTime() - date2.getTime()) /(24*60*60*1000)); var giorni=parseInt((dat1 - dat2) /(24*60*60*1000)); //_saldo_2 if (giorni <= 0) {giorni = 0;} return giorni; } function FormatNumberBy3(num) { sep = ","; decpoint = "."; num = num.toString(); a = num.split(decpoint); x = a[0]; // decimal y = a[1]; // fraction z = ""; if (typeof(x) != "undefined") { // reverse the digits. regexp works from left to right. for (i = x.length - 1; i >= 0; i--) z += x.charAt(i); // add seperators. but undo the trailing one, if there z = z.replace(/(\d{3})/g, "$1" + sep); if (z.slice(-sep.length) == sep) z = z.slice(0, -sep.length); x = ""; // reverse again to get back the number for (i = z.length - 1; i >= 0; i--) x += z.charAt(i); // add the fraction back in, if it was there if (typeof(y) != "undefined" && y.length > 0) x += decpoint + y; } return x; } function CurrencyFormatted(amount) { var i = parseFloat(amount); if (isNaN(i)) { i = 0.00; } var minus = ''; if (i < 0) { minus = '-'; } i = Math.abs(i); i = parseInt((i + .00501) * 100); // _new 18/01/2014 i = i / 100; s = new String(i); if (s.indexOf('.') < 0) { s += '.00'; } if (s.indexOf('.') == (s.length - 2)) { s += '0'; } s = minus + s; s = FormatNumberBy3(s); s = ReplaceAll(s, ".", "#"); s = ReplaceAll(s, ",", "."); s = ReplaceAll(s, "#", ","); return s; } function ReplaceAll(Source, stringToFind, stringToReplace) { var temp = ''; if (Source !=undefined) var temp = Source; var index = temp.indexOf(stringToFind); while (index != -1) { temp = temp.replace(stringToFind, stringToReplace); index = temp.indexOf(stringToFind); } return temp; } function ReplaceAll2(Source, stringToFind, stringToReplace) { var temp = ''; if (Source !=undefined) var temp = Source; temp = temp.replace(new RegExp(stringToFind, 'g'), stringToReplace); return temp; } function numerico(num){ // console.log(num); var nnum = num +""; nnum = nnum.replace(".", ""); nnum = nnum.replace(",", "."); return eval(nnum); } function numericov(num){ // console.log(num); var nnum = num +""; nnum = nnum.replace(".", "#"); nnum = nnum.replace(",", "."); nnum = nnum.replace("#", ","); return nnum; } /* function esiste(str){ return $('#'+str).length > 0; } var isset = function(obj, props) { if ((typeof (obj) === 'undefined') || (obj === null)) return false; else if (props && props.length > 0) return isset(obj[props.shift()], props); else if (obj.length > 0) return true; else return false; }; */ function isset () { // http://kevin.vanzonneveld.net // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + improved by: FremyCompany // + improved by: Onno Marsman // + improved by: Rafal Kukawski // * example 1: isset( undefined, true); // * returns 1: false // * example 2: isset( 'Kevin van Zonneveld' ); // * returns 2: true var a = arguments, l = a.length, i = 0, undef; if (l === 0) { throw new Error('Empty isset'); } while (i !== l) { if (a[i] === undef || a[i] === null) { return false; } i++; } return true; } function PostUrl(URLtarget, valoreParametro) { if (window.DOMParser) { var TipoBrowser = 'FF'; } else { var TipoBrowser = 'IE'; } if (document.getElementById('formPostUrl')){ var removeForm=document.getElementById('formPostUrl'); document.body.removeChild(removeForm); } if (TipoBrowser == 'IE') { // var txtform = "
"; //_new 28/05/2013 var txtform = ""; //_new 28/05/2013 var ftarget = document.createElement(txtform); } else { var ftarget = document.createElement("form"); ftarget.setAttribute("name", "formPostUrl"); ftarget.setAttribute("id", "formPostUrl"); ftarget.setAttribute("method", "post"); ftarget.setAttribute("action", URLtarget); ftarget.setAttribute("target", "_blank"); //_new 28/05/2013 } var parametro = document.createElement("input"); parametro.setAttribute("type", "hidden"); parametro.setAttribute("name", "json2"); parametro.setAttribute("id", "json2"); parametro.setAttribute("value", valoreParametro); ftarget.appendChild(parametro); document.body.appendChild(ftarget); if (document.getElementById("formPostUrl")) { document.getElementById("formPostUrl").submit(); } else { alert('Errore nella chiamata al server'); return false; } document.body.removeChild(ftarget); return true; } function PostUrlEx(URLtarget, valoreParametro,target) { if (target=="undefined") target='_blank'; if (window.DOMParser) { var TipoBrowser = 'FF'; } else { var TipoBrowser = 'IE'; } if (document.getElementById('formPostUrl')){ var removeForm=document.getElementById('formPostUrl'); document.body.removeChild(removeForm); } if (TipoBrowser == 'IE') { // var txtform = ""; //_new 28/05/2013 var txtform = ""; //_new 28/05/2013 var ftarget = document.createElement(txtform); } else { var ftarget = document.createElement("form"); ftarget.setAttribute("name", "formPostUrl"); ftarget.setAttribute("id", "formPostUrl"); ftarget.setAttribute("method", "post"); ftarget.setAttribute("action", URLtarget); ftarget.setAttribute("target", target); //_new 28/05/2013 } /*var parametro = document.createElement("input"); parametro.setAttribute("type", "hidden"); parametro.setAttribute("name", "json2"); parametro.setAttribute("id", "json2"); parametro.setAttribute("value", valoreParametro); ftarget.appendChild(parametro); */ var params = parseQuery(valoreParametro); for (var i in params) { if (params.hasOwnProperty(i)) { var input = document.createElement('input'); input.type = 'hidden'; input.name = i; input.value = params[i]; ftarget.appendChild(input); } } document.body.appendChild(ftarget); if (document.getElementById("formPostUrl")) { document.getElementById("formPostUrl").submit(); } else { alert('Errore nella chiamata al server'); return false; } document.body.removeChild(ftarget); return true; } function parseQuery(qstr) { var query = {}; var a = qstr.split('&'); for (var i in a) { var aa = a[i]; if (typeof aa === 'string') { // PER COLPA DI NELLO var b = aa.split('='); query[decodeURIComponent(b[0])] = decodeURIComponent(b[1]); } } return query; } function searchStringInArray (str, strArray) { if (str!="") for (var j=0; j 150) popupTop=100; document.getElementById(mydiv).style.position='fixed'; document.getElementById(mydiv).style.left=popupLeft+'px'; document.getElementById(mydiv).style.top=popupTop+'px'; document.getElementById('divSfondo').style.visibility='visible'; document.getElementById('divSfondo').style.height = altezzaDocumento + 'px'; document.getElementById(mydiv).style.visibility='visible'; document.getElementById(mydiv).style.width=larghezza+'px'; $(document).keypress(function(e) { // Enable esc if (e.keyCode == 27) { $('.cancelbutton').click(); } }); $('#'+mydiv).addClass("asdivdrag"); $(".asdivdrag").draggable({ containment: "window",handle:".asdivdrag"}); // $(".asdivdrag").draggable({ containment: "window",handle:".asdivdrag", cancel: ".divdrag"}); // $(".asdivdrag").draggable({ containment: "window", cancel: ".divdrag"}); $("#divSfondo").click(function() { $('.cancelbutton').click(); }); } function togliFinestra(){ $('#forminput').remove(); $('#divSfondo').remove(); } function datefromYYYYMMAA(s){ var data = null; if (s!="" && s!=0){ var s_a = s.substring(0,4); var s_m = s.substring(4,6); var s_d = s.substring(6,8); // data = new Date(s_a+'-'+s_m+'-'+s_d); data = new Date(s_a , s_m -1, s_d, 0, 0, 0, 0); } return data; } function HideTooltip(){ $('.ui-tooltip').remove(); return true; } // dataIn es. 20130521 in 21/05/2013 function DateAAAAMMGGtostr(dataIn){ if (dataIn=="0" || dataIn=="" || typeof (dataIn) === 'undefined') return ""; var aaaa = N2S(dataIn.substr(0,4),4); var mm = N2S(dataIn.substr(4,2),2); var gg = N2S(dataIn.substr(6,2),2); return gg + '/'+ mm + '/' + aaaa; } // dataIn date in 20130521 function DatetostrAAAAMMGG(dataIn){ var dat = '00000000'; if (isDate(dataIn)){ var aaaa = N2S(dataIn.getFullYear(),4); var mm = N2S(dataIn.getMonth()+1,2); var gg = N2S(dataIn.getDate(),2); dat =aaaa+""+mm+""+gg; } return dat; } // dataIn date in 20130521 function Datetostr(dataIn){ var dat = ''; if (isDate(dataIn)){ var aaaa = N2S(dataIn.getFullYear(),4); var mm = N2S(dataIn.getMonth()+1,2); var gg = N2S(dataIn.getDate(),2); dat =gg+"/"+mm+"/"+aaaa; } return dat; } // dataIn es. 21/05/2013 in data function strToDate(dataIn){ var data = null; if (dataIn!="" && dataIn!=0){ var s_d = dataIn.substring(0,dataIn.indexOf('/')); dataIn=dataIn.substring(dataIn.indexOf('/')+1,dataIn.length+1); var s_m = parseInt(dataIn.substring(0,dataIn.indexOf('/'))); dataIn=dataIn.substring(dataIn.indexOf('/')+1,dataIn.length+1); var s_a =dataIn; data = new Date(s_a , s_m -1, s_d, 6, 0, 0, 0); } return data; } // dataIn es. 20130521 in data function strAAAAMMGGToDate(dataIn){ var data = null; if (dataIn!="" && dataIn!=0){ var s_a = dataIn.substring(0,4); var s_m = dataIn.substring(4,6); var s_d = dataIn.substring(6,8); data = new Date(s_a , s_m -1, s_d, 6, 0, 0, 0); } return data; } function sxDateDiff2(date1, date2) { dat1 = Date.UTC(date1.getFullYear(),date1.getMonth(), date1.getDate()) ; //_saldo_2 dat2 = Date.UTC(date2.getFullYear(),date2.getMonth(), date2.getDate()) ;//_saldo_2 var giorni=parseInt((dat1 - dat2) /(24*60*60*1000)); //_saldo_2 return giorni; } /****************/ function ControllaCF(cf) { var validi, i, s, set1, set2, setpari, setdisp; if( cf == '' ) return ''; cf = cf.toUpperCase(); if( cf.length != 16 ) return "La lunghezza del codice fiscale non e'\n" +"corretta: il codice fiscale dovrebbe essere lungo\n" +"esattamente 16 caratteri.\n"; validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; for( i = 0; i < 16; i++ ){ if( validi.indexOf( cf.charAt(i) ) == -1 ) return "Il codice fiscale contiene un carattere non valido `" + cf.charAt(i) + "'.\nI caratteri validi sono le lettere e le cifre.\n"; } set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ"; setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX"; s = 0; for( i = 1; i <= 13; i += 2 ) s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) ))); for( i = 0; i <= 14; i += 2 ) s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) ))); if( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) ) return "Il codice fiscale non e' corretto:\n"+ "il codice di controllo non corrisponde.\n"; return ""; } function ControllaPIVA(pi) { if( pi == '' ) return ''; if( pi.length != 11 ) return "La lunghezza della partita IVA non e'\n" + "corretta: la partita IVA dovrebbe essere lunga\n" + "esattamente 11 caratteri.\n"; validi = "0123456789"; for( i = 0; i < 11; i++ ){ if( validi.indexOf( pi.charAt(i) ) == -1 ) return "La partita IVA contiene un carattere non valido `" + pi.charAt(i) + "'.\nI caratteri validi sono le cifre.\n"; } s = 0; for( i = 0; i <= 9; i += 2 ) s += pi.charCodeAt(i) - '0'.charCodeAt(0); for( i = 1; i <= 9; i += 2 ){ c = 2*( pi.charCodeAt(i) - '0'.charCodeAt(0) ); if( c > 9 ) c = c - 9; s += c; } if( ( 10 - s%10 )%10 != pi.charCodeAt(10) - '0'.charCodeAt(0) ) return "La partita IVA non e' valida:\n" + "il codice di controllo non corrisponde.\n"; return ''; } function validateCodFis(campo) { cod = $.trim(document.getElementById(campo).value); err = ''; if (cod == '') { document.getElementById("err_"+campo).innerHTML = ""; return true; } else if (cod.length == 16) err = ControllaCF(cod); else if (cod.length == 11) err = ControllaPIVA(cod); else err = "Il codice introdotto non e' valido:\n\n" + " - un codice fiscale deve essere lungo 16 caratteri;\n\n" + " - una partita IVA deve essere lunga 11 caratteri.\n"; if (err > '') { document.getElementById("err_"+campo).innerHTML = "Codice fiscale non valido"; } else { document.getElementById("err_"+campo).innerHTML = ""; return true; } } function ControllaEmail(emails){ var testresults = ""; var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i; var emails = cod.split(','); for (var i = 0, limit = emails.length; i < limit; i++) { if (!filter.test(emails[i])){ if (testresults=="") testresults = "Email non valido"; } } return (testresults); } function validateEmail(campo) { cod = $.trim(document.getElementById(campo).value); err = ''; if (cod == '') { document.getElementById("err_"+campo).innerHTML = ""; return true; } else err = ControllaEmail(cod); if (err > '') { document.getElementById("err_"+campo).innerHTML = "Email non valido"; } else { document.getElementById("err_"+campo).innerHTML = ""; return true; } } function selectSiNo(a,b) { var s=""; if (a==b) { s=' selected="true" ';} return s; } function myShow(str){ $(str).css('display','block'); } // crea una data senza ora function newDate(){ var dataOut=new Date(); dataOut.setHours(6,0,0,0); return dataOut; } function HtmlEncode(s) { return $('
').html(s).text(); } function aggiornaOggetto(oggettoVecchio,oggettoNuovo){ if ((typeof(oggettoNuovo)=="object") || (typeof(oggettoNuovo)=="array")){ for (var property in oggettoNuovo){ if ((typeof(oggettoNuovo[property])=="object") || (typeof(oggettoNuovo[property])=="array")){ if (isset(oggettoVecchio[property])){ aggiornaOggetto(oggettoVecchio[property],oggettoNuovo[property]); }else{ if (typeof(oggettoNuovo[property])=="object"){ if (oggettoNuovo[property] instanceof Date){ oggettoVecchio[property]=oggettoNuovo[property]; // copia la data }else{ oggettoVecchio[property]={}; for (var item in oggettoNuovo[property]){ oggettoVecchio.property=item; } } }else{ oggettoVecchio[property]=new Array(); for (var item in oggettoNuovo[property]){ oggettoVecchio[property].push(item); } } } }else{ if (! isset(oggettoVecchio[property])){ oggettoVecchio[property]=oggettoNuovo[property]; } } } } return true; } /* function isDate (x) { return (null != x) && !isNaN(x) && ("undefined" !== typeof x.getDate); } */ function isChecked(id){ var res = false; if($(id).is(':checked')) res = true; return res; } function setChecked(id,valore){ $(id).prop('checked', valore); } function setSelected(id,valore){ $(id + " [value='"+valore+"']").attr("selected","selected"); } function isVisible(id){ var res = false; if($(id).is(':visible')) res = true; return res; } function setVisible(id,valore){ if (valore) myShow(id); else myHide(id); } function myHide(str){ $(str).hide(); } /* function N2S(num,dim){ var snum = ''; snum = num.toString(); while (snum.length < dim ){ snum = "0"+snum; } return snum; } */ function Arr_Remove(arr, item) { for(var i = arr.length; i--;) { if(arr[i] === item) { arr.splice(i, 1); } } } function dateFromISO(s) { s = s.split(/\D/); return new Date(Date.UTC(s[0], --s[1]||'', s[2]||'', s[3]||'', s[4]||'', s[5]||'', s[6]||'')) } function nvl(oggetto,valoreDefault){ if (typeof(oggetto)=="string"){ if (oggetto.toUpperCase()=="NULL"){ return valoreDefault; } } if (isEmpty(oggetto)){ return valoreDefault; }else{ return oggetto; } } function isEmpty(s) { return ((s == null) || (s.length == 0)) } function dataUguale(data1, data2){ if (!(data1 instanceof Date)){ return false; } if (!(data2 instanceof Date)){ return false; } if ((data1.getFullYear()==data2.getFullYear()) && (data1.getMonth()==data2.getMonth()) && (data1.getDate()==data2.getDate())){ return true; }else{ return false; } } function inObjArray(oggetto, arrayOggetti) { // Restituisce la posizione di un oggetto in un array di oggetti della stessa classe (-1 = non trovato) var risultato=-1; oggettoSuccessivo: for (var i=0; i < arrayOggetti.length; i++){ var oggettoArray=arrayOggetti[i]; proprietaSuccessiva: for (var proprieta in oggetto){ if (! oggettoArray.hasOwnProperty(proprieta)){ return risultato; } if (oggettoArray[proprieta] instanceof Date){ if (oggetto[proprieta] instanceof Date){ if (dataUguale(oggettoArray[proprieta],oggetto[proprieta])){ if ((risultato != i) && (risultato >= 0)){ risultato=-1; continue oggettoSuccessivo; }else{ risultato=i; continue proprietaSuccessiva; } }else{ risultato=-1; continue oggettoSuccessivo; } } } if (oggettoArray[proprieta] == oggetto[proprieta]) { if ((risultato != i) && (risultato >= 0)){ risultato=-1; continue oggettoSuccessivo; }else{ risultato=i; } }else{ risultato=-1; continue oggettoSuccessivo; } } if (risultato >= 0){ return risultato; } } return risultato; } function esiste(str){ return $('#'+str).length > 0; } function esistename(str){ return $("[name='"+str+"'").length > 0; } function cloneDR(o) { //const gdcc = "__getDeepCircularCopy__"; var gdcc = "__getDeepCircularCopy__"; if (o !== Object(o)) { return o; // primitive value } var set = gdcc in o, cache = o[gdcc], result; if (set && typeof cache == "function") { return cache(); } // else o[gdcc] = function() { return result; }; // overwrite if (o instanceof Array) { result = []; for (var i=0; iy) sor = 1; if (key2 != ''){ if (x==y && x2y2) sor = 1; } return sor; }); } function sortByKeyNum(array, key) { return array.sort(function(a, b) { var x = a[key]; var y = b[key]; return x-y; }); } function DataFromCF(cf) { var tabellamesi = { "A" : "01", "B" : "02", "C" : "03", "D" : "04", "E" : "05", "H" : "06", "L" : "07", "M" : "08", "P" : "09", "R" : "10", "S" : "11", "T" : "12" }; var dat = cf.replace(/^(?:\w{6})(\d{2})(\w)(\d{2}).+$/, function(data, aa, mm, gg) { var anno = parseInt(aa, 10); var secolo = (anno < 9)? '20':'19'; anno = [secolo, aa].join(''); var giorno = parseInt(gg, 10); var sesso = (giorno > 31)? 'F' : 'M'; if (sesso === 'F') giorno -= 40; var mese = mm.toUpperCase(); mese = tabellamesi[mese]; return [N2S(giorno,2), N2S(mese,2), N2S(anno,4)].join("/"); }); if (isDate(strToDate(dat))) { return dat; } else{ return ''; } } function MFFromCF(cf) { var sesso =''; if (typeof cf == "string") { if (cf.length==16) { var gg = cf.charAt(9); // solo il decimo carattere var G = parseInt(gg, 10); if (G>=0 && G<4) { sesso ='M' } if (G>3 && G<8) { sesso ='F' } } } return sesso; } Num_omocodia={"0":0,"1":1,"2":2,"3":3,"4":4,"5":5,"6":6,"7":7,"8":8,"9":9, "L":0,"M":1,"N":2,"P":3,"Q":4,"R":5,"S":6,"T":7,"U":8,"V":9}; function checkomocodia(cf) { if (typeof cf == "string") { if (cf.length==16) { // !todo } } } function DateAddGG(datein,GG){ var d=new Date(datein); d.setDate(d.getDate()+GG); return d; } /* mik 14/01/2016 */ function deleteAllRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; for (var i = 1; i < rowCount; i++) { var row = table.rows[i]; table.deleteRow(i); rowCount--; i--; } } function strdateok(data){ var s = false; var data1=strToDate(data); s = isDate(data1); if (isDate && data1!= null){ if (data==Datetostr(data1) && data1.getFullYear() > 1800 && data1.getFullYear() < 2100) { return true; } } return false; } function caricacombo(combo,myarr){ var myCombo= $('#'+combo); var html = ''; $('#'+combo+' option').each(function() { $(this).remove(); }); html = ""; var arr = myarr; for (var i in arr) { if (arr[i] != null) { var htmld = ''; html += ''; } } if (html != "") { myCombo.append(html); } $('#'+combo).val(''); }