HTML Javascript转换程序
HTML Javascript converter program
我试图创建一个简单的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>
现在工作更好了…但重置的方向是什么呢?如何格式化输出?所有新手问题都是yes
<!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>
将函数转换为以下格式
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.
相关文章:
- 在谷歌应用程序脚本中转换为空格的制表符
- 为什么我的javascript程序没有将其转换为整数而不是字符串
- 有没有一种简单的方法可以将ExtJS 4 MVC应用程序转换为ExtJS DeftJS MVC
- YUI应用程序转换”;闪烁”;在showView上
- 将ExtJs的Web应用程序转换为桌面应用程序
- 如何使用 JSP 和 Javascript 将 Applet 应用程序转换为 Web 应用程序
- Firefox 插件中的 OnBeforeRequest URL 重定向(从 Chrome 扩展程序转换)
- 如何将 Chrome 扩展程序转换为 Chrome 应用程序
- 将网络应用程序转换为移动应用程序
- 如何将node.js应用程序转换为cordova
- 将三星智能电视应用程序转换为在浏览器中工作
- 从安卓应用程序转换而来的黑莓10应用程序的javascript调用java函数
- 当从ember.js1.11.3升级到1.12以删除弃用警告时,我如何将这些初始化程序转换为实例初始化程序
- 如何将内联在HTML中的JavaScript事件处理程序转换为参数化
- 将简单的javascript程序转换成C语言
- 将web应用程序转换为mac上的全屏桌面应用程序
- 使用Appcelerator将基于web2py的web应用程序转换为本地应用程序是否容易?可能的
- 将Javascript应用程序转换为Windows应用程序
- 可以将web应用程序转换为google chrome应用程序吗?
- 是否有可能将Dashcode Webkit Web应用程序转换为“正常”?HTML + css