Location: PHPKode > projects > PhpProjectMaster > www/template/common/form_js.html
<script type="text/javascript">
<!--
var DataFormChanged=0;
function input_changed(){
 DataFormChanged=1;
}
function cancel_form(loc){
 if (DataFormChanged){
    if (confirm('`There are unsaved changes. Do you really want to Cancel editing the Form?`')){
       window.location=loc;
    }
 } else {
   window.location=loc;
 }
 return false;
}

function delete_btn(loc){
 if (confirm('`ARE YOU SURE to delete this item?`')) {window.location=loc}
 return false;
}

function get_formfield(Frm,Fld){
 var d=document;
 var x;
 for (i=0;!x&&i<d.forms.length;i++) if(d.forms[i].name==Frm) x=d.forms[i][Fld];
 return x;
}

function PopUpCalendar(Frm,Fld){
 //search for fld first
  window.dateField = get_formfield(Frm,Fld);
  calendar = window.open('<~ROOT_URL>/popup_cal.htm','cal','WIDTH=200,HEIGHT=250');
  return false;
}

function PopUpRichEditor(Frm,Fld){
 //search for fld first
  window.richeditField = get_formfield(Frm,Fld);;
  richedit = window.open('<~ROOT_URL>/popup_richedit.htm','cal','WIDTH=430,HEIGHT=115');
  return false;
}

function setCBValue(CtrlSel,Ctrl){
 if (CtrlSel){
    if (CtrlSel.selectedIndex>=0){
       Ctrl.value=CtrlSel.options[CtrlSel.selectedIndex].value;
    }
 }
}
function getCBValue(CtrlSel){
 var res='';
 if (CtrlSel){
    if (CtrlSel.selectedIndex>=0){
       res=CtrlSel.options[CtrlSel.selectedIndex].value;
    }
 }
 return res;
}

function resetCB(fcombo){
 var fld=get_formfield('DataF', fcombo);
 if (fld && fld.selectedIndex>-1){
    fld.selectedIndex=-1;
 }
}

function chkDigits(flag){  //for onKeyPress="chkDigits()"
 var keycode=window.event.keyCode;
 if (!flag && (keycode>=48 && keycode<=57 || keycode==44 || keycode==46) ||     //digits and ,.
     flag==1 && (keycode>=48 && keycode<=57) ||     //digits only
     flag==3 && (keycode>=48 && keycode<=57 || keycode==45) ||     //digits and -
     flag==4 && (keycode>=48 && keycode<=57 || keycode==47) ||     //digits and /
     flag==5 && (keycode>=48 && keycode<=57 || keycode==32) ||     //digits and space
     flag==2 && (keycode>=48 && keycode<=57 || keycode==44 || keycode==46 || keycode==37) ||      //digits and ,.%
     flag==6 && (keycode>=48 && keycode<=57 || keycode==58)     //digits and :
    ){
    window.event.returnValue = true;
 }
 else{
    window.event.returnValue = false;
 }
}

function input_check_len(elem, is_check, min_value, max_value){
 if (!is_check) return;

 var inputStr = elem.value;
 var strlength= inputStr.length;
 if (strlength > max_value ) elem.value=inputStr.substring(0,max_value);
// frm.lastchar.value = (max_value - elem.value.length);
 elem.focus();
}

function make_table_list(tbl, url){
 var jtbl=$(tbl);
 $("tbody tr:even", tbl).addClass('even');
 $("tbody tr:odd", tbl).addClass('odd');
 $("tbody tr", tbl).hover(function(){
   $(this).addClass("hover");
 },function(){
   $(this).removeClass("hover");
 })
 .dblclick(function(){
   if (url) window.location=url;
 });

}

//-->
</script>
Return current item: PhpProjectMaster