Click here to Skip to main content
16,007,111 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
" it is not displaying the value of the variable where as it is displaying the variable name in the html output page. I tried different things but none of them works and my knowledge in HTML and Javascript is not good. Can anybody help me to display a script vaiable value inside an HTML table data.

Thanks in Advance.
Posted
Updated 9-Jan-17 20:44pm
v2
Comments
Sergey Alexandrovich Kryukov 6-Oct-14 15:59pm    
Not enough information. A comprehensive but shortest possible code sample can help a lot.
—SA
code4Better 7-Oct-14 0:45am    
<!-- creating an instance of my C# class to get the C# functions. I will be registring the class with regasm.exe-->
<object id="Object1" classid="clsid:cc12f78-67fe-4c22-9364-cdb743c22aa5"> </object>

<script language="javascript" type="text/javascript">
var resultValue= document.ctrlPanel.ReturnMessage();
alert(resultValue); <!-- correct value is getting poped in the alert window-->
</script>

<!-- Table for displying the output -->
<table id=Table2 style="width: 200px; font: 8pt Arial;">

<tr id="Tr5" style="height: 22px;">

<!--display output value here-->
<td id ="opValue">resultValue</td>

<!--output value displayed is simplt the text 'resultValue'. It is not displaying the value of the variable. How to display the value of the variable??-->

</tr>

</Table>
analogx 6-Oct-14 16:05pm    
Can you please tell what and how you have tried?
Then may be we can help you
analogx 6-Oct-14 16:06pm    
Try using innerText on td tag of your table
MANIARASAN SIVASERAN 7-Oct-14 0:01am    
A piece of your code would suffice to help you...kindly upload the coding part

Try this it worked for me!!

String result = function();//function return string
"<tr><td>"+result+"</td></tr>"
 
Share this answer
 
v3
Comments
Member 13169801 22-Aug-19 22:12pm    
Hey Buddy I don't really know who you are but I want you to know that I searched for this answer for hours and hours and then I saw your solution. Simply Amazing. Thank you for this post. It helped a lot.
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> 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900