Home >Web Front-end >JS Tutorial >Example js code for value transfer between subform and parent form_javascript skills

Example js code for value transfer between subform and parent form_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:27:391134browse
Copy code The code is as follows:

//Return the value to the parent form
function returnParent(value ) {//Get the child form return value
var parent = window.dialogArguments; //Get the parent page
//parent.location.reload(); //Refresh the parent page
if (parent ! = null && parent != "undefined") {
window.returnValue = value; //Return value
window.close(); //Close the subpage
}
//window.opener .document.getElementById("ActivityPic");//Directly operate the parent form element
//$(selector, window.parent.document); used for frame page
//$(selector, window. opener.document); This is suitable for pages that are opened separately
return;
}
//Open the modal subform and get the return value for operation
function showModalOnly(me, url) { //Pop up Form, radio selection
var hidden = document.getElementById(me); //Get the hidden control
if (hidden != null && hidden.value != null && hidden.value.length > 0) {
alert("This is a radio selection, please delete the existing options first and try to select again.");
return;
}
var reValue = window.showModalDialog(url, window , "dialogHeight:500px; dialogWidth:987px; status:off; scroll:auto");
if (reValue == null || reValue == "undefined" || reValue == "") {
return ; //If the return value is empty, return
}
var index = reValue.split("^"); //The position of the separator ^
if (index[0] == null | | index[0] == "undefined" || index[0].length < 1) {
return;
}
var hid = index[0].split('&'); //Assign value to hidden control
var view = index[1].split('&'); //Display value
var content = ""; //Content that needs to be added to check
if (hid != null && hid.length == 2) {
var i = 0;
if (hid[i] != "undefined" && hid[i] != "" && view[i 1 ] != "undefined" && view[i 1] != "") {
content = 'Delete';
hidden.value = hid[i]; //Assign value to hidden control
var c = document.getElementById("check" me);
c.innerHTML = content;
return;
}
}
alert("Please select only one piece of data. ");
return;
}
function openUploadWindow(url, width, height,left,top) {
if(width==null) width=987;
if (height = = null) height = 500;
if (left == null) left = 200;
if (top == null) top = 200;
//window.open(url, 'newwindow', 'height=' height ',width=' width ',top=200,left=200,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
window.showModalDialog(url, window, "dialogHeight:" height "px; dialogWidth:" width "px;status:off; scroll:auto;dialogLeft:" left "px;dialogTop:" top "px");
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
' view[i 1] '