如何在html表中分配脚本变量值 [英] How to assign a script variable value inside an html table
本文介绍了如何在html表中分配脚本变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是HTML 4.01。在HTML中我调用了函数并返回一个字符串值。返回值在名为var returnValue的变量中捕获。当我弹出一个带警报功能的消息时,我的'returnValue'有预期的输出值。
现在我的问题是,我希望HTML中的'returnValue'变量值表。当我在td(表数据)中编写代码时
returnValue |
先谢谢。
Hi,
I am using HTML 4.01. In HTML i called and function which returns a string value. The return value is captured in a variable named 'var returnValue'. When i popup a message with alert function, my 'returnValue' has expected output value.
Now my question is, i want value of 'returnValue' variable inside an HTML table. When i wrote code inside td (table data)
"
returnValue |
Thanks in Advance.
推荐答案
试试这个:
Try this:
<!DOCTYPE html>
<html>
<head>
<script>
function concat(){
var first= document.getElementById("first").value;
var second = document.getElementById("second").value;
var result = document.getElementById("result");
result.innerText = first + " " + second;
}
</script>
</head>
<body>
<input type="text" id="first" value="hello">
<input type="text" id="second" value="world">
<button onclick="concat()">Concat</button>
<div id="result">waiting for result</div>
</body>
</html>
试试这个对我有用!!
字符串结果= function(); / / function return string
< tr>< td>+ result +< / td>< / tr>
Try this it worked for me!!
String result = function();//function return string
"<tr><td>"+result+"</td></tr>"
这篇关于如何在html表中分配脚本变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文