使用JavaScript使得Select标签无需按钮直接跳转的方法

常用教程评论1,307阅读模式

加入这段javascript。在页头。

<SCRIPT language=javascript>
		function mbar(sobj) {
		                                 var docurl =sobj.options[sobj.selectedIndex].value;
		                                 if (docurl != "") {
						        open(docurl,'_self');
						        sobj.selectedIndex=0;
						         sobj.blur();
						         }
						}
</SCRIPT>

用PHP输入指定的字符文章源自原紫番博客-https://www.yuanzifan.com/54469.html

</select>页<!--YuanzifanUpdate End-->					
			
          <!--YuanzifanUpdate Start-->
			<select onchange=mbar(this) name="select">
	<?PHP	for($xPageCode=1;$xPageCode<=$total_Page_nums;$xPageCode++)
		        echo "<option value=\"$RedirectURL$xPageCode\">".$xPageCode."</a></option>"			
	?>				
			</select>页<!--YuanzifanUpdate End-->

用For循环写入Select 的Value,然后Value设置成超链接。文章源自原紫番博客-https://www.yuanzifan.com/54469.html

这个Select 的标签要加上onChange事件,这个事件就是跳转。文章源自原紫番博客-https://www.yuanzifan.com/54469.html

文章源自原紫番博客-https://www.yuanzifan.com/54469.html 文章源自原紫番博客-https://www.yuanzifan.com/54469.html

 

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:
确定

拖动滑块以完成验证