• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

奋斗中...

曾经的程序员。ASP.NET/C#, JavaScript, PL/SQL, T-SQL; 工具: VS2003/2005, Oracle, SQLServer; 偶尔写点CSS, 批处理.
头脑中经常有新想法, 可惜没有去实现.
Never give up.
Never get into a fight with a pig. Both of you will get dirty. But the pig actually enjoys it.
  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

[转载][javascript]获取HTML控件的值

from: http://www.pczpg.com/html/bianchengkaifa/js/20091108/22559.html

 

1.下拉列表框选定值
  ddlPageSize.options[ddlPageSize.selectedIndex].value

取选中选项的文本

  ddlPageSize.options[ddlPageSize.selectedIndex].text

  ddlPageSize.options[ddlPageSize.selectedIndex].innerText

 

复选框
  $get('chkGoogle').checked

 

控件隐藏与显示:
  document.getElementById("控件名").style.display='' //显示, 或者block

  document.getElementById("控件名").style.display='none'

 

textBox:
   document.getElementById("控件名").value        //获取或设值文本框值
 

checkbox:
   document.getElementById('chkComJoin').checked //判断是否已选择
 
   example:
    if(document.getElementById('chkComJoin').checked)
            document.getElementById('trcomjoin').style.display=''
       
label:
   document.getElementById("控件名").innerHTML   //获取或设值标签值


网址验证:
   var urlreg1=/^[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/
                if (!urlreg1.test(a.value))//验证网址
                {
                    document.getElementById("lblCheckWebFormat2").innerHTML="请正确录入企业网址!";
                } else {
                     document.getElementById("lblCheckWebFormat2").innerHTML="";
                }

 

防止返回字符为类型 :
   if(typeof(返回值变量)!="undefined")

 

table添加行:  

  insertRow()
  insertCell()
        表ID.rows(0).cells(0).innerText   或   innerHTML //获取或设值某单元格

      var curRow=document.getElementById(表ID).rows.count;//得到表的最大行数,作为插入位置(第几行)
      var x=document.getElementById(name).insertRow(curRow); //插入一行在curRow位置,并定义x行对象
      var C1=x.insertCell(0);//插入一个单元格(列)在0位置,并定义C1列对象
      var C2=x.insertCell(1);
      var C3=x.insertCell(2);
      var C4=x.insertCell(3);
      var C5=x.insertCell(4);
      C1.innerHTML=ary[0];//为单元格赋值,
      C1.style.display='none';
      C2.innerHTML=ary[1];
      C2.style.display='none';
      C3.innerHTML='<a href=\"'+ary[0]+'\" target=\"_blank\">'+ary[2]+'</a>';
      C4.innerHTML=ary[3];
      C4.style.display='none';
      C5.innerHTML="<input type=\"button\" value=\"删除\"
      onclick=\"if(confirm('确实要删除当前项吗?')){DelteFile     ('"+ary[0]+';'+aryof1+"');this.parentNode.parentNode.removeNode(true)}\">";


日期控件使用:
   将日期控件放入弹出的新页面中,"<base target="_self"></base>"加入<HEAD></HEAD>之间
    <script>
    //返回值
    function getValue(Value) {
           window.returnValue=Value;
           window.close();
    }
    </script>


posted on 2010-12-29 14:10  jes  阅读(1630)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3