我正在使用javascript在html文本框中存储一些值,我想将其存储到 [英] i am storing some values in html text box using javascript i want to store it in to a

查看:69
本文介绍了我正在使用javascript在html文本框中存储一些值,我想将其存储到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script type="text/javascript">

        function addthis(tid, val1) {
            if (tid.checked) {
                document.getElementById("resdiv").innerText = parseInt(document.getElementById("resdiv").value) + parseInt(val1);


            }
            else {
                document.getElementById("resdiv").innerText = parseInt(document.getElementById("resdiv").value) - parseInt(val1);
            }

        }


    </script>




< input type ="text" id ="resdiv" value ="0"/>

在代码C#中
我用过

session ["xyz"] = request.form ["resdiv"];这不起作用
我也用过runat ="server"但不能正常工作

任何解决方案




<input type="text" id="resdiv" value="0" />

in code C#
i used

session["xyz"] = request.form["resdiv"]; which is not working
i used runat = "server" also but not working

any solution

推荐答案

<input type="text"  runat="server" id="resdiv" />

<script type="text/javascript">
 
function addthis(tid, val1) 
{
 if (tid.checked) 
  {
  document.getElementById("resdiv").innerHTML = parseInt(document.getElementById("resdiv").value) + parseInt(val1);
  }
 else
  {
   document.getElementById("resdiv").innerHTML = parseInt(document.getElementById("resdiv").value) - parseInt(val1);
  }
}
 

    </script>




试试这个,它将起作用.




Try This , it will work .



如果您使用runat ="server"


然后直接在服务器端识别该ID

就像resdiv.value =

当您在代码中键入ID时,智能会向您显示该ID.

还有一件事是文本框值是通过javascript中的value属性访问的,而不是innertext


您在客户端(通过JavaScript或通过用户交互)设置的所有最佳
hi
if you use runat="server"


then just u''ll c that id directly in server side

like resdiv.value=

intellegency show you that id when you type that in code.

and one more thing is textbox values are access by value property in javascript not innertext


All the Best


值,即使是在提交字段(即runat = server)中,也只能在服务器端使用在提交页面后.您必须提交主页表单才能重新运行服务器脚本.
Values you set on the client side (in JavaScript or via user interaction), even into submitted fields (i.e. runat=server), will only be available on the server side after a page submit. You must submit the main page form to re-run your server scripts.


这篇关于我正在使用javascript在html文本框中存储一些值,我想将其存储到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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