java 动态修改prooper_JS动态对表单进行添加和修改

这段Java代码展示了如何动态地对表单进行操作,包括查询商品、设置商品、清空表单以及保存和提交功能。通过JavaScript交互,实现对表单中商品选择后的单位显示、数量验证以及动态添加和修改物品到表格。
摘要由CSDN通过智能技术生成

Title

import="java.util.Date"%>

市局办公用品-新个人申领

type="text/css">

//dwr.engine.setAsync(false);

var csbh="";

var goodsindex=0;

function submitButton(obj)

{

if(obj.value==""){

return;

}

OfficeSuppliesLogic.queryGoods(obj.value,csbh,setGoods);

}

function handleSetSelectIndexAsValue(destSideId,value){

var destSide=document.getElementById(destSideId);

if(destSide==null)return;

for(var j=0;j

if(destSide.options[j].value==value){

destSide.selectedIndex=j;

break;

}

}

}

function setGoods(data){

handleRemoveAll("goods");

if(data==null ||data=='null'){return;}

for(var i=0;i

var officeSuppliesModel=data[i];

if(officeSuppliesModel==null ||officeSuppliesModel=='null' ){continue;}

var goodsId=officeSuppliesModel.id;

var goodsName=officeSuppliesModel.name;

var goodsUnit=officeSuppliesModel.unit;

handleAdd("goods",goodsId+"|"+goodsUnit,goodsName);

}

}

function backClick()

{

document.forms[0].method.value="queryExamePersonSuppliesByUser";

return true;

}

function saveClick()

{

document.forms[0].typeName.value=document.forms[0].typeId.options[document.forms[0].typeId.selectedIndex].text;

document.forms[0].goodsName.value=document.forms[0].goods.options[document.forms[0].goods.selectedIndex].text;

count=document.forms[0].goodsName.value;

if(count==null || count.length<=0)

{

alert('物品名称不能为空!');

document.forms[0].goodsName.value='';

return false;

}

count=document.forms[0].applyCount.value;

if(count==null || count<='0')

{

alert('数量不能小(等)于零或为空!');

document.forms[0].applyCount.value='';

return false;

}

return true;

}

function startClick()

{

var checknum=0;

var checkBoxs=document.getElementsByName("applyid");

for(var i=0;i

if(checkBoxs[i].checked){

checknum=checknum+1;

}

}

if(checknum==0){

alert("可提交的申请项为空,请选择申请项后进行提交!");

return false;

}

document.forms[0].method.value="createPersonSuppliesDraw";

return true;

}

function goodChange()

{

var val=document.forms[0].goods.options[document.forms[0].goods.selectedIndex].value;

var arry=val.split('|');

try{

document.forms[0].unit.value=arry[1];

document.forms[0].goodsId.value=arry[0];

if(document.getElementById('display').hasChildNodes())

{

document.getElementById('display').removeChild(document.getElementById('display').childNodes[0]);

}

//   document.getElementById('display').removeChild(document.getElementById('display'));

document.getElementById('display').appendChild(document.createTextNode(arry[1]));

}catch(e)

{}

}

function addGoods(){

if(!saveClick()){

return;

}

var opertype=document.forms[0].opertype.value;

var typeName=document.forms[0].typeId.options[document.forms[0].typeId.selectedIndex].text;

var typeId=document.forms[0].typeId.options[document.forms[0].typeId.selectedIndex].value;

var goodsName=document.forms[0].goods.options[document.forms[0].goods.selectedIndex].text;

var goods_id="-1";

var unit="";

var val=document.forms[0].goods.options[document.forms[0].goods.selectedIndex].value;

var arry=val.split('|');

try{

unit=arry[1];

goods_id=arry[0];

}catch(e)

{}

var applyCount=document.forms[0].applyCount.value;

var table=document.getElementById("bgyptable");

if(opertype==""){

var newTr = table.insertRow(table.rows.length-1);

newTr.id=goodsindex;

var newTd0 = newTr.insertCell();

newTd0.className="table2_td";

newTd0.innerHTML=typeName+""

+"";

var newTd1 = newTr.insertCell();

newTd1.className="table2_td";

newTd1.innerHTML=goodsName+""

+""

+"";

var newTd3 = newTr.insertCell();

newTd3.className="table2_td";

newTd3.innerHTML=applyCount+unit+"";

var newTd6 = newTr.insertCell();

newTd6.className="table2_td";

newTd6.innerHTML="修改";

goodsindex=goodsindex+1;

}else{

for(var i=0;i

obj=table.rows[i];

if(obj.cells.length<3||obj.cells[3].getElementsByTagName("input").length==0||obj.cells[3].getElementsByTagName("input")[0].type!="checkbox"){

continue;

}

var rowid=obj.cells[3].getElementsByTagName("input")[0].value;

if(rowid==opertype){

obj.cells[0].innerHTML=typeName+""

+"";

obj.cells[1].innerHTML=goodsName+""

+""

+"";

obj.cells[2].innerHTML=applyCount+unit+"";

document.forms[0].opertype.value="";

document.getElementById("okbutton").value="增加到申请列表";

}

}

}

document.forms[0].applyCount.value="";

// document.forms[0].guige.value="";

//document.forms[0].typeId.selectedIndex=0;

//document.forms[0].goods.selectedIndex=0;

}

function setModify(obj){

var id=obj.cells[3].getElementsByTagName("input")[0].value;

document.forms[0].opertype.value=id;

document.forms[0].applyCount.value=obj.cells[2].getElementsByTagName("input")[0].value;

//document.forms[0].guige.value=obj.cells[3].getElementsByTagName("input")[0].value;

handleSetSelectIndexAsValue("typeId",obj.cells[0].getElementsByTagName("input")[0].value);

submitButton(document.getElementById("typeId"));

handleSetSelectIndexAsValue("goods",obj.cells[1].getElementsByTagName("input")[1].value+"|"+obj.cells[1].getElementsByTagName("input")[2].value);

document.getElementById("okbutton").value="确定";

}

     >place_btn.gif

width="12" height="11">

当前位置:北京市药监局 >> 辅助办公 >> 办公用品申请

cellspacing="0" class="table1_border">

     >table1_head_ico.gif

width="26" height="23" align="absmiddle">

办公用品领用登记

var count=0;

align="center" cellpadding="0" cellspacing="1"

class="table2_border">

所属类别

名称

数量

是否提交

οnchange="submitButton(this);">

value=""

selected

/>

value="|"

selected />

οnclick="javascript:addGoods()">

cellpadding="0" cellspacing="1" class="table2_border">

src="btnSubmit.gif"

οnclick="return startClick()">

src="btnBack.gif"

οnclick="return backClick()">

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值