You can achieve this one very easily using jQuery.
For this you have to include the jQuery file to your page where you want to make use of it.
For me the jquery file is at root of the project itself.
<script src="jquery-2.0.3.js"></script>
Here is an example as per your code description :-
In page let say we have two elements like
1. Button
<input type="button" class="btn" id="btnSeven" value="Generate Birthday" />
2. TextBox
<input type="text" name="textBox" id="textBox" />
Then to set the textbox value on click of button by calling the method which returns the value :-
$(function () {
$("#btnSeven").on("click", function () {
$("#textBox").val(myfunction());
});
});
function myfunction() {
return "myvalue";
}
Hope this will help. Please let me know if you need any more help on it.