单击按钮时设置表单变量 [英] Set a form variable when button is clicked

查看:108
本文介绍了单击按钮时设置表单变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮我用JavaScript编写代码.我是新手.

我有保存按钮.单击保存"按钮后,我目前将其配置为<输入类型=按钮VALUE =保存" ONCLICK ="savemethod()">

我需要编写代码,以便在单击保存按钮时,需要在savemethod()中设置表单变量,以便以后可以在代码中使用该变量.

将变量设置为某种值(整数或true)后,我将编写如下内容:
如果saveformvariable = true/1
然后写入数据库(我的意思是更新数据库),否则不要更新.

单击按钮时如何设置表单变量.有人可以帮我吗?

这有点紧急
提前非常感谢.

Can anyone help me to write the code in JavaScript. I am new to it.

I have the save button. When Save button is clicked which I presently configured like "<INPUT TYPE=button VALUE="Save" ONCLICK="savemethod()">

I need to write the code so that when the save button is clicked, I need to set the form variable in savemethod() so that I can use that variable later in the code.

After it sets the variable to something(either integer or true), I will write something like this:
If saveformvariable = true/1
then write to database (i mean update to database) else Don''t update.

How can I set the form variable when the button is clicked. Can someone help me out please?

It is a bit urgent
Thanks a lot in advance.

推荐答案

使用document.getElementById(),如此处所述:

http://msdn.microsoft.com/en-us/library/ms536437(VS .85).aspx
Use document.getElementById() as discussed here:

http://msdn.microsoft.com/en-us/library/ms536437(VS.85).aspx


这篇关于单击按钮时设置表单变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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