May 11, 2010

rarely use syntax in JavaScript & Mysql but useful

// clear select value
object = document.getElementById("test");
object.options.length = 1;
<input type="text" autocomplete="off" />
document.forms["myform"].submit();


//====== Detect browser with style attribute.
if(navigator.appName=="Netscape"){
if(chk_obj.checked){
temp_obj.removeAttribute("style","display:block;");
}else{
temp_obj.value='';
temp_obj.setAttribute("style","display:none;");
}
}else{
if(chk_obj.checked){
temp_obj.style.setAttribute("cssText","display:block;");
}else{
temp_obj.value='';
temp_obj.style.setAttribute("cssText","display:none;");
}
}


// Mysql syntax which helps me from converting a string into date field:
STR_TO_DATE(String_date,'%d/%m/%Y');
STR_TO_DATE('01,5,2013','%d,%m,%Y');
STR_TO_DATE('01,5,2013','%d-%m-%Y');