现在的位置: 首页 > 综合 > 正文

html 控件使用

2013年01月20日 ⁄ 综合 ⁄ 共 2734字 ⁄ 字号 评论关闭
INPUT 文本输入框:
 
<script language="javascript">
function toSum1()
{
 document.Form1.Text1.value="ltp";
 document.Form1.Text2.style.backgroundColor="#669999";
}
 
 
function selecttext() { document.Form1.TextBox6.select(); }
 
 
</script>
 
失去焦点: onblur="toSum1()"
 
鼠标过来进,出移开效果:onmouseover="b()" onmouseout="h()"  (Button也可使用)
 
有关其他事件查看:  HTMLInputTextElementEvents Dispinterface
 
 
设置html控件:
 
 
   this.Text1.Style["BORDER-TOP-STYLE"]="none";
   this.Text1.Attributes["readOnly"]="readOnly";
   text6.Attributes["onclick"]="select()";

 

我们在WEB项目中,有时候需要在用户点击某个东西的时候,一些东西不可用。如果在客户端实现。最简单的就是利用disabled 。下面罗列的其中三种方式:

依次是:不可用(disabled);用一个空白来代替这个地方(Blank);这个区域为空(None)。具体可以查看这个Blog的源文件:

dadd

ccc

这三种方式其实核心代码依次是:

obj.disabled = false;

obj.style.visibility = "hidden";

obj.style.display = "none";

我把这三种收集到一起,供以后查找使用方便。

<!--演示代码开始//-->
<SCRIPT language=javascript>
function ShowDisableObject(obj)
{
 if(obj.disabled == false)
 {
  obj.disabled = true;
 }
 else{
  obj.disabled = false;
 }
 var coll = obj.all.tags("INPUT");
 if (coll!=null)
 {
  for (var i=0; i<coll.length; i++)
  {
   coll[i].disabled = obj.disabled;
  }
 }
}
 
function ShowBlankObject(obj)
{
 if(obj.style.visibility == "hidden")
 {
  obj.style.visibility = "visible";
 }
 else
 {
  obj.style.visibility = "hidden";
 }
}
 
function ShowNoneObject(obj)
{
 if(obj.style.display == "none")
 {
  obj.style.display = "block";
 }
 else
 {
  obj.style.display = "none";
 }
}
 
</SCRIPT>

display-Possible Values

block Object is rendered as a block element.块元素(会换行)
none Object is not rendered.
inline Default. Object is rendered as an inline element sized by the dimensions of the content.内流元素(不换行)
inline-block Object is rendered inline, but the contents of the object are rendered as a block element. Adjacent inline elements are rendered on the same line, space permitting.
list-item   IE6 and later. Object is rendered as a block element, and a list-item marker is added.
table-header-group Table header is always displayed before all other rows and row groups, and after any top captions. The header is displayed on each page spanned by a table.
table-footer-group Table footer is always displayed after all other rows and row groups, and before any bottom captions. The footer is displayed on each page spanned by a table.
隐藏html控件
<input type=text name=txt1 style="display:none">
document.xxx.style.display="none";
Table 使用
 
1。
<asp:table id="Table2" style="BORDER-COLLAPSE: collapse" runat="server" Width="100%" GridLines="Both" BorderWidth="1px" BorderColor="DimGray">
<asp:TableRow>
<asp:TableCell BackColor="#ddddd5" align="center" Text="单位"></asp:TableCell>
<asp:TableCell BackColor="#ddddd5" align="center" Text="上报日期"></asp:TableCell>
</asp:TableRow>
</asp:table>
 
 
设置字体:cell1.Font.Size=FontUnit.Smaller;
style="BORDER-COLLAPSE: collapse" 属性是不显示表格凸出的边框,改为平框
 
 
2。单元格鼠标移动效果
 
<tr id="test"
onmouseover="javascript:this.bgColor='#FFDDAA'"
onmouseout="javascript:this.bgColor='#FFFFF5'"
bgColor="#fffff5">
<td vAlign="middle" align="center" colSpan="2">指定日规则列表</td>
</tr>

抱歉!评论已关闭.