JavaScript、HTML、JSP onClick语句

JavaScript、HTML、JSP onClick语句,javascript,html,jsp,Javascript,Html,Jsp,是否有方法将文本字段中的值用作按钮onclick语句中的参数值。例如,如果您有一个名为“name”的文本字段,并且单击时有另一个名为“button”的按钮,则将转到同一页面“page.jsp”,参数“par”等于文本字段值。这就是我目前正在做的: out.print("<input type = 'button' name = 'noName' value = 'Click Me' onclick =" + '"' + "window.location.href = 'http://pag

是否有方法将文本字段中的值用作按钮onclick语句中的参数值。例如,如果您有一个名为“name”的文本字段,并且单击时有另一个名为“button”的按钮,则将转到同一页面“page.jsp”,参数“par”等于文本字段值。这就是我目前正在做的:

out.print("<input type = 'button' name = 'noName' value = 'Click Me' onclick =" + '"' + "window.location.href = 'http://page.jsp?par=" + document.form.name.value + "'" + '"');
out.print(“
String s=“
String s=“像这样打印吗?”

<script>
    function doSomething(txt){
        alert(txt);   //alert the text maybe?
        //do more things...
    }
</script>
<input onClick="doSomething(this.value)">

函数doSomething(txt){
警告(txt);//可能会警告文本吗?
//做更多的事情。。。
}
this.value
表示文本字段中的值。

像这样吗

<script>
    function doSomething(txt){
        alert(txt);   //alert the text maybe?
        //do more things...
    }
</script>
<input onClick="doSomething(this.value)">

函数doSomething(txt){
警告(txt);//可能会警告文本吗?
//做更多的事情。。。
}

此.value
表示文本字段中的值。

谢谢,我知道我在运行什么。谢谢,我知道我在运行什么。