本文介绍了按钮单击后如何将Javascript函数值传递给文本框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的HTML代码



here is my html codes

<input type="text" name="textBox" id="textBox"/>

<a input type="button" class="btn" id="btnSeven" >Generate Birthday</a>







这是我的javascript函数






this is my javascript function

<script>
        function myFunction()
        {
        alert("Page is loaded");
        }







document.getElementById('btnSeven').onclick =  myFunction(){
 document.getElementById('textBox').value = document.getElementById('btnSeven').value;





});



< / script>



现在我想在单击按钮后将函数值传递给文本框。



});

</script>

now i want to pass function value to text box after i clicked the button.

推荐答案

<script src="jquery-2.0.3.js"></script>





以下是根据您的代码说明的示例: -



页面上说我们有两个元素,比如

1.按钮



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



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 :-




这篇关于按钮单击后如何将Javascript函数值传递给文本框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 00:16
查看更多