//Query the database for qualified data function SelectAlterNativeVenues(field) { var xmlhttp; var pid = document.getElementById("nameandaddress").value; var url = "${RetrieveURL}?accessorType=${AccessorType}"; url = url "&method=RetrieveSelectResult&NameAndAddress=" escape(pid); if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //IE } if (xmlhttp != null) { xmlhttp.open("GET", url, true); xmlhttp.setRequestHeader("If-Modified-Since", "0"); xmlhttp.send(null); xmlhttp.onreadystatechange = function processRefreshUsers() //Registration method { if (xmlhttp.readyState == 4) { if (xmlhttp .status == 200) { //responseXML gets the return value of executing the RetrieveCitiesByProvinceId method var datas = xmlhttp.responseXML.documentElement.getElementsByTagName("AlterNativeVenues"); var nname = document. getElementById("table1"); var pchildren = nname.childNodes;//Clear the rows and columns in the table for(var a=0; a{ nname.removeChild(pchildren[a]); } //Add query row var aaRow=nname.insertRow(0); var aaCell=aaRow.insertCell(0); aaCell.innerHTML=""; aaRow.insertCell(1).innerHTML="Query"; //Add title row var aRow=nname .insertRow(1); aRow.insertCell(0).innerHTML=""; aRow.insertCell(1).innerHTML="name"; aRow.insertCell(2).innerHTML=" Address"; aRow.insertCell(3).innerHTML="Phone"; //Loop to add data rows for (i = 0; i < datas.length; i ) { var Id = datas[i].getElementsByTagName("Id")[0].firstChild.nodeValue; var Name = datas[i].getElementsByTagName("Name")[0].firstChild.nodeValue; var Address=datas[i].getElementsByTagName("Address")[0].firstChild.nodeValue; var Phone=datas[i].getElementsByTagName("Phone")[0].firstChild.nodeValue;
//Add selected data function AddRowSelectAfter(id,field) { //Divide all the ids in the hidden field and bind the corresponding checked var state =false; //Determine whether the following list exists var _hiddenId=document.getElementById(field).value.substr(0,document.getElementById(field).value.length-1).split(','); for(j=0;j<_hiddenId.length;j ) { if(_hiddenId[j]==id.split('_')[1]) { state=true; }
} if(state==false) { //Just click the checkbox to change the value of the hidden field once / /In the unselected state, the id needs to be removed from the hidden control var arrs=document.getElementById(field).value.substr(0,document.getElementById(field).value.length-1).split(', '); //Define a field to retrieve the id var newids=""; for(var arr=0;arr{ if( arrs[arr]!=id.split('_')[1]) newids =arrs[arr] ","; } //Reassign the hidden control // The last character may be, var fh=newids.substr(newids.length-1,newids.length); if(fh==",") document.getElementById(field).value =newids.substr(0,newids.length-1); else document.getElementById(field).value=newids;
if(document.getElementById(id). checked==false) { //Click to change the selected state to non-clicked state to remove the selected venue document.getElementById(id).checked=false; //Give tr Set the id to delete tr document.getElementById("table2").deleteRow(document.getElementById("NewRow_" id.split('_')[1]).rowIndex);
} else { document.getElementById(id).checked=true; var input =document.getElementById(field); var xmlhttp; var url = "${ RetrieveURL}?accessorType=${AccessorType}"; url = url "&method=SelectResult&id=" id; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); //IE } if (xmlhttp != null) { xmlhttp.open("GET", url, true); xmlhttp.setRequestHeader("If-Modified-Since", "0"); xmlhttp.send(null); xmlhttp.onreadystatechange = function processRefreshUsers() //Registration method { if (xmlhttp.readyState == 4) { if ( xmlhttp.status == 200) { //responseXML gets the return value of executing the RetrieveCitiesByProvinceId method var datas = xmlhttp.responseXML.documentElement.getElementsByTagName("AlterNativeVenues"); var nname = document .getElementById("table2"); nname.style.width="560px"; if(nname.rows.length==0&&datas.length>0) { //First Row var firstRow=nname.insertRow(0); firstRow.id="NewRow_0"; firstRow.insertCell(0).innerHTML="name"; firstRow.insertCell(1) .innerHTML="Address"; firstRow.insertCell(2).innerHTML="Phone"; firstRow.insertCell(3).innerHTML="Operation"; } for (i = 0; i < datas.length; i ) { var Id = datas[i].getElementsByTagName("Id")[0].firstChild.nodeValue; var Name = datas[i] .getElementsByTagName("Name")[0].firstChild.nodeValue; var Address=datas[i].getElementsByTagName("Address")[0].firstChild.nodeValue; var Phone=datas[i] .getElementsByTagName("Phone")[0].firstChild.nodeValue;
var aNewRow=nname.insertRow(nname.rows.length); aNewRow.id="NewRow_" Id; var oneCell=aNewRow.insertCell(0); oneCell.innerHTML=Name; oneCell.width=140; var twoCell=aNewRow.insertCell(1); twoCell.innerHTML=Address; twoCell.width=280; var threeCell=aNewRow.insertCell(2); threeCell.innerHTML=Phone; threeCell.width=100; var fourCell=aNewRow.insertCell( 3); fourCell.innerHTML="Delete "; fourCell.width=40; if(input.value!="") input.value =","; input.value =Id; } } } } } } } }
function DeleteRow(id,obj,field) { obj. parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode) var nname = document.getElementById("table2"); if(nname.rows.length==1) { nname.deleteRow(0); } //The above list does not exist after the query has been stored in the database if(document.getElementById("AlterNativeVenues_" id)!=null||document.getElementById ("AlterNativeVenues_" id)!=undefined) { if(document.getElementById("AlterNativeVenues_" id).checked==true) { document.getElementById("AlterNativeVenues_" id) .checked=false; } } //Unchecked state requires removing the id from the hidden control var arrs=document.getElementById(field).value.substr(0,document .getElementById(field).value.length-1).split(','); //Define a field to get the id again var newids=""; for(var arr=0; arr{ if(arrs[arr]!=id) newids =arrs[arr] ","; } //Hide again Control assignment //Reassign the hidden control //The last character may be, var fh=newids.substr(newids.length-1,newids.length); if(fh ===",") { document.getElementById(field).value=newids.substr(0,newids.length-1); } else document.getElementById( field).value=newids; }
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