调用来自文本框按钮,并输入javascript函数 [英] Calling javascript function with button and input from textbox

查看:131
本文介绍了调用来自文本框按钮,并输入javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网页文本框和按钮。我有几套的下面不同的目的。

 <输入类型=文本ID =新NAME =新值=1/>
<输入类型=按钮值=编辑的onclick =计算(编辑(XXX)); />

一旦点击此按钮,我想调用javascript函数,将采取在文本框中输入值。现在我想知道我怎么想检索输入'新'的值,并将它传递的XXX作为参数?


解决方案

 <输入类型=按钮值=编辑的onClick =计算(编辑(的document.getElementById( 。'新')值))/>

这是你如何在HTML处理它。

否则,你可以使用JavaScript编写同一code。

 函数编辑()
{
     X =的document.getElementById('新')值;
     //使用这个X.
}

I have a textbox and button in my page. I have several sets of the below for different purpose.

<input type="text" id="new" name="new" value="1" />
<input type="button" value="Edit" onclick="compute(edit(xxx));" />

Upon clicking on the button, I want to call a javascript function which will take in the value input in the textbox. Now I am wondering how am I suppose to retrieve the value from the input 'new' and pass it the 'xxx' as argument?

解决方案

<input type="button" value="Edit" onClick="compute(edit(document.getElementById('new').value))" />

This is how you handle it there in the HTML.

Else you can write the same code in javaScript.

function edit()
{
     x = document.getElementById('new').value;
     //use this X.
}

这篇关于调用来自文本框按钮,并输入javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆