通达OA工作流列表控件获取数据,JSON回传,参数保存txt文本

本文介绍了一个使用JavaScript和jQuery实现的表单功能,其中包括禁用特定输入框及通过AJAX请求从PHP后端获取数据来更新表单内容的具体实现细节。

1、表单上的js代码:

function getinventory(cinvcode){
	var resobj;
	jQuery.ajax({type:'POST',
			url:'indexliebiao.php?c=workflow&m=getcinvname',
			data:{cinvcode:cinvcode,  //第一个参数
                   name:'第二个参数'//第二个参数
                  },
			success:function(res){
				resobj=res;
			},
			dataType:'json',
			async:false,cache:false}
		);
	return resobj;
}		
jQuery(function(){
	//第二列不能输入
    jQuery("td[id^='LV_57'][id$='_c2'] input").live('keypress keydown',function(event){
      
		return false;
	});	
	//第一列输入代码后调出名称
	//jQuery("td[id$='_c1'] input").live('click',function(event){
  jQuery("td[id^='LV_57_'][id$='_c1'] input").live('blur',function(event){
		var cinvcode=jQuery(this).val();
      alert(cinvcode);
		var tdid=jQuery(this).parent().attr('id');
      alert(tdid);
		var tdary=tdid.split('_');
		var rowidx=tdary[2].substr(1);//行号	
      alert(rowidx);
		var objtdid=tdary[0]+'_'+tdary[1]+'_'+tdary[2]+'_c2';
      alert(objtdid);
		if (cinvcode==''){
			jQuery("td[id='"+objtdid+"'] input:eq(0)").val('');
			return;
		}
      	jQuery("td[id='"+objtdid+"'] input:eq(0)").val('赋新值');
		var res=getinventory(cinvcode);		
   		 alert(res.rescode);
		if (res.rescode==0){
			jQuery("td[id='"+objtdid+"'] input:eq(0)").val(res.resmsg);
		}else{
		jQuery("td[id='"+objtdid+"'] input:eq(0)").val('');
		}
	});
});








2、php 路径:E:\MYOA\webroot\general\workflow\list\input_form\indexliebiao.php

<?
include_once("inc/auth.inc.php");  
include_once("inc/utility_all.php");  
//php  为gb2312的格式
$cinvcode=$_POST["cinvcode"];
$name=$_POST["name"];
$c1=$_GET["c"];

$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt =$cinvcode."--".$c1."--".$name."Bill Gates\n";
fwrite($myfile, $txt);
$txt = $cinvcode."Steve Jobs\n";
fwrite($myfile, $txt);
fclose($myfile);

$arr=array("rescode"=>0,"resmsg"=>iconv("gb2312","utf-8","汉字需要转编码"));
echo json_encode($arr);
?>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hai7425

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值