Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
HTML Javascript转换程序_Javascript_Html - Fatal编程技术网

HTML Javascript转换程序

HTML Javascript转换程序,javascript,html,Javascript,Html,我试图创建一个简单的HTML程序,允许用户输入一个数字或单词,然后如果userInput与我定义的内容匹配,它会将该输入更改为其他内容,然后在屏幕上输出新值 同时寻找重置程序的按钮(随时重新启动) 有什么想法吗 <!DOCTYPE html> <html> <body> <h1>Value Converter</h1> <input type="text" id="userInput"=>Enter the Val

我试图创建一个简单的HTML程序,允许用户输入一个数字或单词,然后如果
userInput
与我定义的内容匹配,它会将该输入更改为其他内容,然后在屏幕上输出新值

同时寻找重置程序的按钮(随时重新启动)

有什么想法吗

<!DOCTYPE html>
<html>
<body>
  <h1>Value Converter</h1>

  <input type="text" id="userInput"=>Enter the Value</input>
  <button onclick="test()">Submit</button>
  <script>
    function test() {
      var userInput = document.getElementById("userInput").value;

      //Need to add If, else if, else to change the value of userInput
      // for example, If xxxx value, set to yyyy, then output yyyy 

      document.write(userInput);
    }           
    // Need to add a "reset" to go back to restart the program

    </script>
</body>
</html>    

值转换器
输入值
提交
功能测试(){
var userInput=document.getElementById(“userInput”).value;
//需要添加If,else If,else来更改userInput的值
//例如,如果xxxx值设置为yyyy,则输出yyyy
document.write(用户输入);
}           
//需要添加“重置”才能返回以重新启动程序
与…一起工作会更好。。。但是重置去了哪里?如何格式化输出?所有的问题都是肯定的

<!DOCTYPE html>
<html>
<body>
<h1>Value Converter</h1>

<input type="text" id="userInput"=>Enter the Value</input>
    <button onclick="test()">Submit</button>
    <script>
        function test()
            {
   var userInput = document.getElementById("userInput").value;
   if(userInput == "xxxx") {
      userInput="yyyy";
   }
   else if(userInput == "yyyy") {
      userInput="zzzz";
   }
   else {
      userInput="Not Found";
   }
        document.write(userInput);  
            }

            // Need to add a "reset" to go back to restart the program

    </script>
</body>
</html> 

值转换器
输入值
提交
功能测试()
{
var userInput=document.getElementById(“userInput”).value;
如果(用户输入=“xxxx”){
userInput=“yyy”;
}
else if(userInput==“yyyy”){
userInput=“zzzz”;
}
否则{
userInput=“未找到”;
}
document.write(用户输入);
}
//需要添加“重置”才能返回以重新启动程序

将函数转换为以下内容

function test()
{
   var userInput = document.getElementById("userInput").value;
   if(userInput == "xxxx") {
      // I forgot the updating part here. 
      document.getElementById("otherIdToWriteOutput").innerHTML = "yyyy";
   }
}
您还可以添加重置按钮。并使用删除当前文本

document.getElementById("id").innerHTML = ""; // remove the inner html.

将函数转换为以下内容

function test()
{
   var userInput = document.getElementById("userInput").value;
   if(userInput == "xxxx") {
      // I forgot the updating part here. 
      document.getElementById("otherIdToWriteOutput").innerHTML = "yyyy";
   }
}
您还可以添加重置按钮。并使用删除当前文本

document.getElementById("id").innerHTML = ""; // remove the inner html.

将函数转换为以下内容

function test()
{
   var userInput = document.getElementById("userInput").value;
   if(userInput == "xxxx") {
      // I forgot the updating part here. 
      document.getElementById("otherIdToWriteOutput").innerHTML = "yyyy";
   }
}
您还可以添加重置按钮。并使用删除当前文本

document.getElementById("id").innerHTML = ""; // remove the inner html.

将函数转换为以下内容

function test()
{
   var userInput = document.getElementById("userInput").value;
   if(userInput == "xxxx") {
      // I forgot the updating part here. 
      document.getElementById("otherIdToWriteOutput").innerHTML = "yyyy";
   }
}
您还可以添加重置按钮。并使用删除当前文本

document.getElementById("id").innerHTML = ""; // remove the inner html.



-1因为
document.write在初始页之后调用的函数中没有意义output@devnull69,错过了那部分我现在已经编辑了这篇文章。:)有意义吗?@devnull69,有什么建议吗?)我会喜欢的。重置代码去哪里了?它不起作用,我如何格式化输出在屏幕和H1的中间,并且在它下面有一个重置按钮?这是我猜的另一个问题。user3798473,-1,因为
document.write
在初始页之后调用的函数中没有意义output@devnull69,错过了那部分我现在已经编辑了这篇文章。:)有意义吗?@devnull69,有什么建议吗?)我会喜欢的。重置代码去哪里了?它不起作用,我如何格式化输出在屏幕和H1的中间,并且在它下面有一个重置按钮?这是我猜的另一个问题。user3798473,-1,因为
document.write
在初始页之后调用的函数中没有意义output@devnull69,错过了那部分我现在已经编辑了这篇文章。:)有意义吗?@devnull69,有什么建议吗?)我会喜欢的。重置代码去哪里了?它不起作用,我如何格式化输出在屏幕和H1的中间,并且在它下面有一个重置按钮?这是我猜的另一个问题。user3798473,-1,因为
document.write
在初始页之后调用的函数中没有意义output@devnull69,错过了那部分我现在已经编辑了这篇文章。:)有意义吗?@devnull69,有什么建议吗?)我会喜欢的。重置代码去哪里了?它不起作用,我如何格式化输出在屏幕和H1的中间,并且在它下面有一个重置按钮?这是我猜的另一个问题。user3798473,
document.write
/
writeln
仅在页面加载时有用。不要试图在活动中使用它。谢谢!转换器正在处理您的想法。但是重置不起作用,它去哪里了?如何将输出格式设置为更大,并在屏幕中间设置一个重置按钮?从输入什么额外的<代码>=<代码>?它应该查找匹配项,如果找到,则将其更改为新值?
文档。write
/
writeln
仅在页面加载时有用。不要试图在活动中使用它。谢谢!转换器正在处理您的想法。但是重置不起作用,它去哪里了?如何将输出格式设置为更大,并在屏幕中间设置一个重置按钮?从输入什么额外的<代码>=<代码>?它应该查找匹配项,如果找到,则将其更改为新值?
文档。write
/
writeln
仅在页面加载时有用。不要试图在活动中使用它。谢谢!转换器正在处理您的想法。但是重置不起作用,它去哪里了?如何将输出格式设置为更大,并在屏幕中间设置一个重置按钮?从输入什么额外的<代码>=<代码>?它应该查找匹配项,如果找到,则将其更改为新值?
文档。write
/
writeln
仅在页面加载时有用。不要试图在活动中使用它。谢谢!转换器正在处理您的想法。但是重置不起作用,它去哪里了?如何将输出格式设置为更大,并在屏幕中间设置一个重置按钮?从输入什么额外的<代码>=<代码>?它应该查找一个匹配项,如果找到了,是否将其更改为新值?