js 提交和设置表单的值
程序员文章站
2023-11-29 16:50:16
<input type="button" id="btnudf7" name="btnudf7" style="<%=showudf7flag&&showudfbtn7flag? "":"display:none;"%>" value=". . ." class="btnlook" style="" onclick="openlookupgen(arrsetaweight, arrgetaweight ,'<%=eusutil.getpage("lookup.generic.bucode.s")%>?udfindex=7&codelabel='+encodeuricomponent(getudfstr('7')), '', 640, 480, 'yes')">
var arrsetaweight = new array();
var arrgetaweight = new array();
var arraweightparam = new array();
arrsetaweight[0] = "document.impdeclform.udfvalue7";
arrgetaweight[0] = "document.bucodesearch.codefield";
function openlookupgen(arrsetfield,arrgetfield,strpage,arrparam,width,height,scroll,left,top)
{
var browsertype;
wx = 640; wy = 480;
var x, y;
var x1 = parseint(left);
var y1 = parseint(top);
if (isnan(x1))
{
x = (screen.width - wx)/2;
}
else
{
x = x1;
}
if (isnan(y1))
{
y = (screen.height - wy)/2;
}
else
{
y = y1;
}
str = navigator.appname.touppercase();
if (str.indexof("netscape") >= 0)
{
browsertype = "nn";
}
else
{
browsertype = "ie";
}
var strurl = "";
if (strpage.indexof("?") >= 0)
strurl = strpage + "&";
else
strurl = strpage + "?";
for (var i=0; i < arrsetfield.length; i++){
if (i != 0) strurl = strurl + "&";
strurl = strurl + "setfield" + i + "=" + arrsetfield[i];
strurl = strurl + "&getfield" + i + "=" + arrgetfield[i];
}
if(arrsetfield.length == 0)
strurl = strurl + "nooffield=" + arrsetfield.length ;
else
strurl = strurl + "&nooffield=" + arrsetfield.length ;
for (var i=0; i < arrparam.length; i++){
strurl = strurl + "&" + arrparam[i];
}
//modified by minjie zhu on 2007-01-15
var name="lookup";
if(strpage=="lookupproduct"){
name="";
}
if (browsertype=="nn")
{
//add scrollbars=yes by shuang at 2006-12-20
var win = window.open(strurl, name, "width="+width+",height="+height+",resizable=yes,scrollbars=yes, status=no, menubar=no, toolbar=no,screenx="+x+",screeny="+y);
}
else
{
//add scrollbars=yes by shuang at 2006-12-20
var win = window.open(strurl, name, "width="+width+",height="+height+",resizable=yes, status=no,scrollbars=yes, menubar=no, toolbar=no,left="+x+",top="+y);
}
}
function submitform(fm,pagenumvalue){
fm.pagenum.value=pagenumvalue;
fm.submit();
}
function copyvaluetotarget(str)
{
document.bucodesearch.codefield.value = str;
setvalue();
return true;
}
function setvalue(){
var arrsetfield = new array();
var arrgetfield = new array();
var setobj, getobj;
var strval, strgettype, strsettype;
<% for (int i=0; i < nooffield; i++){
out.println("arrsetfield[" + i + "] = 'opener." + request.getparameter("setfield" + i) + "';");
out.println("arrgetfield[" + i + "] = '" + request.getparameter("getfield" + i) + "';");
}
%>
for (var i = 0; i < <%=nooffield%>; i++){
setobj = eval(arrsetfield[i]);
getobj = eval(arrgetfield[i]);
if (setobj == null)
myalert("setobj null");
if (setobj.type != null)
strsettype = setobj.type;
else
strsettype = setobj[0].type;
if (getobj == null)
myalert("getobj null");
if (getobj.type != null)
strgettype = getobj.type;
else
strgettype = getobj[0].type;
//getting values from lookup form
switch (strgettype){
case "radio":
// get value from lookup radio button
for (var j = 0; j < getobj.length; j++){
if (getobj[j].checked == "1"){
strval = getobj[j].value;
}
}
break;
case "checkbox":
// get value from lookup radio button
if (getobj.checked == true)
strval = getobj.value;
else
strval = "";
break;
case "select-one":
strval = getobj.options[getobj.selectedindex].text;
break;
default:
strval = getobj.value;
break;
}
//setting values into parent form
switch (strsettype) {
case "radio":
// set value for parent radio button
for (var j = 0; j < setobj.length; j++){
if (setobj[j].value.touppercase() == strval.touppercase())
setobj[j].checked = true;
else
setobj[j].checked = false;
}
break;
case "checkbox":
//alert (setobj.value);
//alert (strval);
if (getobj.type == "checkbox")
setobj.checked = getobj.checked;
else if (strval.touppercase() == setobj.value.touppercase())
setobj.checked = true;
else
setobj.checked = false;
break;
case "select-one":
//myalert(setobj.length);
for (var j = 0; j < setobj.length; j++){
//myalert(setobj.options[j].text.touppercase());
if (setobj.options[j].text.touppercase() == strval.touppercase())
setobj.options[j].selected = true;
//else
// setobj.options[j].selected = false;
}
break;
default:
setobj.value = strval;
break;
}
}
opener.focus;
self.close();
}
var arrsetaweight = new array();
var arrgetaweight = new array();
var arraweightparam = new array();
arrsetaweight[0] = "document.impdeclform.udfvalue7";
arrgetaweight[0] = "document.bucodesearch.codefield";
function openlookupgen(arrsetfield,arrgetfield,strpage,arrparam,width,height,scroll,left,top)
{
var browsertype;
wx = 640; wy = 480;
var x, y;
var x1 = parseint(left);
var y1 = parseint(top);
if (isnan(x1))
{
x = (screen.width - wx)/2;
}
else
{
x = x1;
}
if (isnan(y1))
{
y = (screen.height - wy)/2;
}
else
{
y = y1;
}
str = navigator.appname.touppercase();
if (str.indexof("netscape") >= 0)
{
browsertype = "nn";
}
else
{
browsertype = "ie";
}
var strurl = "";
if (strpage.indexof("?") >= 0)
strurl = strpage + "&";
else
strurl = strpage + "?";
for (var i=0; i < arrsetfield.length; i++){
if (i != 0) strurl = strurl + "&";
strurl = strurl + "setfield" + i + "=" + arrsetfield[i];
strurl = strurl + "&getfield" + i + "=" + arrgetfield[i];
}
if(arrsetfield.length == 0)
strurl = strurl + "nooffield=" + arrsetfield.length ;
else
strurl = strurl + "&nooffield=" + arrsetfield.length ;
for (var i=0; i < arrparam.length; i++){
strurl = strurl + "&" + arrparam[i];
}
//modified by minjie zhu on 2007-01-15
var name="lookup";
if(strpage=="lookupproduct"){
name="";
}
if (browsertype=="nn")
{
//add scrollbars=yes by shuang at 2006-12-20
var win = window.open(strurl, name, "width="+width+",height="+height+",resizable=yes,scrollbars=yes, status=no, menubar=no, toolbar=no,screenx="+x+",screeny="+y);
}
else
{
//add scrollbars=yes by shuang at 2006-12-20
var win = window.open(strurl, name, "width="+width+",height="+height+",resizable=yes, status=no,scrollbars=yes, menubar=no, toolbar=no,left="+x+",top="+y);
}
}
function submitform(fm,pagenumvalue){
fm.pagenum.value=pagenumvalue;
fm.submit();
}
function copyvaluetotarget(str)
{
document.bucodesearch.codefield.value = str;
setvalue();
return true;
}
function setvalue(){
var arrsetfield = new array();
var arrgetfield = new array();
var setobj, getobj;
var strval, strgettype, strsettype;
<% for (int i=0; i < nooffield; i++){
out.println("arrsetfield[" + i + "] = 'opener." + request.getparameter("setfield" + i) + "';");
out.println("arrgetfield[" + i + "] = '" + request.getparameter("getfield" + i) + "';");
}
%>
for (var i = 0; i < <%=nooffield%>; i++){
setobj = eval(arrsetfield[i]);
getobj = eval(arrgetfield[i]);
if (setobj == null)
myalert("setobj null");
if (setobj.type != null)
strsettype = setobj.type;
else
strsettype = setobj[0].type;
if (getobj == null)
myalert("getobj null");
if (getobj.type != null)
strgettype = getobj.type;
else
strgettype = getobj[0].type;
//getting values from lookup form
switch (strgettype){
case "radio":
// get value from lookup radio button
for (var j = 0; j < getobj.length; j++){
if (getobj[j].checked == "1"){
strval = getobj[j].value;
}
}
break;
case "checkbox":
// get value from lookup radio button
if (getobj.checked == true)
strval = getobj.value;
else
strval = "";
break;
case "select-one":
strval = getobj.options[getobj.selectedindex].text;
break;
default:
strval = getobj.value;
break;
}
//setting values into parent form
switch (strsettype) {
case "radio":
// set value for parent radio button
for (var j = 0; j < setobj.length; j++){
if (setobj[j].value.touppercase() == strval.touppercase())
setobj[j].checked = true;
else
setobj[j].checked = false;
}
break;
case "checkbox":
//alert (setobj.value);
//alert (strval);
if (getobj.type == "checkbox")
setobj.checked = getobj.checked;
else if (strval.touppercase() == setobj.value.touppercase())
setobj.checked = true;
else
setobj.checked = false;
break;
case "select-one":
//myalert(setobj.length);
for (var j = 0; j < setobj.length; j++){
//myalert(setobj.options[j].text.touppercase());
if (setobj.options[j].text.touppercase() == strval.touppercase())
setobj.options[j].selected = true;
//else
// setobj.options[j].selected = false;
}
break;
default:
setobj.value = strval;
break;
}
}
opener.focus;
self.close();
}