applicable scenario : Multi-condition query case, as shown in:
By setting the URL parameter, combined with the Rul parameter set by the data source control, a simple multi-criteria query can be made.
JavaScript functions:
<mce:script type="Text/javascript"><!--//methods for setting URL parametersfunction Setparmsvalue (parms, parmsvalue) {varUrlstrings =document. URL; varargs =geturlparms (); varValues =Args[parms]; //If the parameter does not exist, add the parameter if(Values = =undefined) { varquery = Location.search.substring (1);//Get query string//If there are already parameters in the URL, the additional parameters if(query) {urlstrings+= ("&"+ Parms +"="+parmsvalue); } Else{urlstrings+= ("?"+ Parms +"="+ Parmsvalue);//Add the first parameter to a URL} window.location=urlstrings; } Else{window.location= Updateparms (parms, Parmsvalue);//Modifying Parameters } } //Modify URL parameter, parms: Parameter name, Parmsvalue: Parameter value, return: Modified URLfunction Updateparms (parms, parmsvalue) {varNewurlparms =""; varNewurlbase = location.href.substring (0, Location.href.indexOf ("?") +1);//intercept the URL in front of the query string varquery = Location.search.substring (1);//Get query string varPairs = Query.split ("&");//Break at comma for(vari =0; i < pairs.length; i++) { varpos = Pairs[i].indexof ('=');//Find Name=value if(pos = =-1)Continue;//If you don't find it, skip it. varArgname = pairs[i].substring (0, POS);//Extract Name varValue = pairs[i].substring (pos +1);//Extract Value//If you find the parameter that you want to modify if(FindText (Argname, parms)) {newurlparms= Newurlparms + (argname +"="+ Parmsvalue +"&"); } Else{newurlparms+ = (Argname +"="+ Value +"&"); } } returnNewurlbase + newurlparms.substring (0, Newurlparms.length-1); } //Auxiliary Methodsfunction FindText (urlstring, KeyWord) {returnUrlstring.tolowercase (). IndexOf (Keyword.tolowercase ())! =-1?true:false; } //get query string parameter collectionfunction geturlparms () {varargs =NewObject (); varquery = Location.search.substring (1);//Get query string varPairs = Query.split ("&");//Break at comma for(vari =0; i < pairs.length; i++) { varpos = Pairs[i].indexof ('=');//Find Name=value if(pos = =-1)Continue;//If you don't find it, skip it. varArgname = pairs[i].substring (0, POS);//Extract Name varValue = pairs[i].substring (pos +1);//Extract ValueArgs[argname] = unescape (value);//Save As Property } returnargs; } --></mce:script>
Test code:
<body> <input type="Button"Id="Button1"onclick="setparmsvalue (' Test1 ', ' AAA ')"Value="set URL parameters [TEST1=AAA]"/> <input type="Button"Id="Button2"onclick="setparmsvalue (' Test1 ', ' BBB ')"Value="set URL parameters [TEST1=BBB]"/> <input type="Button"Id="Button3"onclick="setparmsvalue (' Test2 ', ' AAA ')"Value="set URL parameters [TEST2=AAA]"/> <input type="Button"Id="Button4"onclick="setparmsvalue (' Test2 ', ' BBB ')"Value="set URL parameters [TEST2=BBB]"/> </body>
JavaScript: Methods for setting URL parameters, suitable for multi-criteria queries