Posted on blog.csdn.net/zxub in the early morning.
In actual design, we often need to use the jump menu. After the jump, the page will be refreshed. At this time, we need to make the jump menu display the one we just selected. After trying many methods, I feel like using "menuobj. selectedindex = "is the most direct implementation. Here, variables need to be transferred between pages. I tried it and never passed it over. I don't know what went wrong, so I'm so depressed.
Suddenly, I thought of the address of a dynamic web page, such as AAA = BBB & CCC = DDD. What would happen if I added such an HTML page? I tried it. It is the same as the original one. Okay. You can put the parameters in the address bar and use a document. the location address is down, and the parameter we want is intercepted in the obtained address bar string. This "menuobj. selectedindex = "can be used.
Just like this, the above thought is thrown into the page. The Code is as follows:
<Script language = "JavaScript" type = "text/JavaScript">
Function setselectedindex (OBJ) // OBJ indicates the jump menu
{
VaR selectedindex;
VaR url = Document. location;
VaR serachtaglocation = NULL;
VaR urlstring = "\" "+ URL +" \ ""; // if no value is added, the object does not support this method.
Serachtaglocation = urlstring. indexof ("typeid \ = ");
If (serachtaglocation! =-1)
{
VaR selecttypeid = urlstring. substr (serachtaglocation + 7, 1) // The above is the T location.
VaR optstring = "\" "+ obj. Options [1]. Value +" \ ""; // The following four rows are for my needs.
VaR optserachtaglocation = optstring. indexof ("= ");
VaR opttypeid = optstring. substr (optserachtaglocation + 1, 1)
Selectedindex = selecttypeid-(OptTypeid-1 );
}
Else selectedindex = 0;
OBJ. selectedindex = selectedindex; // you can locate it now.
}
</SCRIPT>
You only need to run the above function after the navigation menu to locate the function. Of course, after the jump, the address must be added with a serial code such as AAA = BBB, it depends on your needs.
Alas ~ Don't speak up, it's finally quite comfortable, hey.