Submit and set the form value in js

Source: Internet
Author: User

<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 ();
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.