create the input control dynamically and assign the value through variable
Dear All,
In my below code , I am able to create the element , But I am willing to assign the value via variable "tempvalue" , Can any one help me in knowing how can I do this
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<script type="text/javascript">
var tempvalue="Something";
function myFunction() {
var txtHTML = "";
//Create Textbox
var textInputBox = $('<input />').attr({
type: "text",
id: "uniqueIdentifier",
// value: "Hello!"
value: '+tempvalue +'
});
//Create table row tag
var tr = $('<tr>');
//Create Table defintion tag
var td = $('<td>');
//Append textbox to td
td.append(textInputBox);
//Append td to tr
tr.append(td);
//append tr to table
$("#tblCustomListData > tbody").append(tr);
}
</script>
</head>
<body >
<button onclick="myFunction()">Try it</button>
<table id="tblCustomListData" border="1" width="100%" style="overflow-x:auto;">
<thead>
<tr class="bgcolorgray">
<th>Sno</th>
<th >Current DR</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</body>
</html>
Thanks
Beginner