使textbox确定javascript变量

使textbox确定javascript变量,javascript,variables,button,textbox,Javascript,Variables,Button,Textbox,我需要一个javascript变量,它是当按下按钮时输入到文本框中的任何内容 基本上,如果有人在文本框中输入“bubbles”,然后单击显示submit的按钮,我需要将“var Item”设置为bubbles。我如何实现这个功能 如果可能的话,我想要一个if语句 var Item = getElementById(whatever the id of the textbox content it) function Thing() { if { getElemen

我需要一个javascript变量,它是当按下按钮时输入到文本框中的任何内容

基本上,如果有人在文本框中输入“bubbles”,然后单击显示submit的按钮,我需要将“var Item”设置为bubbles。我如何实现这个功能

如果可能的话,我想要一个if语句

    var Item = getElementById(whatever the id of the textbox content it)
    function Thing() {
    if {
    getElementById(whatever the id of the textbox content it) = bubbles;
    document.open(P2.html);
    }

您可以获得如下值:

<script>
    function getValue(){
        var value = document.getElementBydId("textbox").value;
    }
</script>
<textarea id="texbox"></textarea>
<button onclick="getValue()">

函数getValue(){
var value=document.getElementBydId(“textbox”).value;
}