Aim is to get value from one input cell and insert to another.
To get value I use
var name = $('#test').val();
And the above works.
Then I need to insert. If I insert simple text (not variable), then it works
$("#test3").val("Dolly Duck");
But how to insert variable (var name) instead of val("Dolly Duck")?
Below if whole code
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
//This works
$("#btn3").click(function(){
$("#test3").val("Dolly Duck");
});
//But his does not work
//at first get value from input form (define variable) and alert to check if it works
var name = $('#test').val();
//alert(name);
//now need to insert
//$("#btn4").click(function(){
//below does not work None of them
//$("#test").name;
//$("#test4").$('#test').val();
//$("#test4").jsvar: $('#test').val();
});
});
</script>
</head>
<body>
<p>Name: <input type="text" id="test" value="Mickey Mouse1"></p>
<p>Name: <input type="text" id="test3" value="Mickey Mouse2"></p>
<p>Name: <input type="text" id="test4" value="Mickey Mouse3"></p>
<button id="btn1">Show Value</button>
<button id="btn3">Set Value</button>
<button id="btn4">Set Value</button>
</body>
</html>
$("#test").val(varName);?name)