日期:2014-05-18  浏览次数:20681 次

html一个简单问题
我要跳转页面,在程序中这样写
    out.println( "Skip   to: "   +   " <input   type=\ "text\ "   name=\ "currentpage\ "> ");现在我想得到这个text的值怎莫得到呢。
out.println( " <a   href=\ "/AddressBook2/display.jsp?page=把得到的值放到这里\ "> "   + "SkipTo "   +   " </a> ");
----
我对html只是能看懂,准备补一下了。


------解决方案--------------------
out.println( "Skip to: " + " <input type=\ "text\ " name=\ "currentpage\ "> ");现在我想得到这个text的值怎莫得到呢。
out.println( " <a href= javascript:getUrl();> " + "SkipTo " + " </a> ");

<script >
function getUrl(){
var v =document.表单名.elements[ "currentpage "].value;
var s = "/AddressBook2/display.jsp?page= "+v;
return s;
}
</script>
------解决方案--------------------
用servlet写比较麻烦,直接用jsp多好.
out.println( "Skip to: " + " <input type=\ "text\ " id=\ "currentpage\ "> ");
out.println( " <a href= '# ' onclick=\ "this.location.href= '/AddressBook2/display.jsp?page= '+document.getElementById( 'currentpage ').value\ "> " + "SkipTo " + " </a> ");