html 控件使用
2004-09-17 20:25
369 查看
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()";
JS 中,一些东西不可用的三种展现方式
我们在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
隐藏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>
<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()";
JS 中,一些东西不可用的三种展现方式
我们在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. |
<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>
相关文章推荐
- 关于使用RadioButton和CheckBox控件(Asp.net)生成html包含<label>控件的一点认识
- asp.net 中 html 控件 File 的使用
- 关于CDHtmlDialog的控制。MFC Web控件的灵活使用
- Html input file控件使用accept过滤 限制的文件类型
- html/js调用ocx控件(activex控件),不能加载,不能使用的原因
- MVC为Html对象建立一个扩展方法,使用自己的控件就像使用TextBox一样方便
- My97DatePicker 日期选择器,使用的时候,如果IE6下打开使用该控件的html会出错 “无法打开站点,已终止操作”
- My97DatePicker 日期选择器,使用的时候,如果IE6下打开使用该控件的html会出错 “无法打开站点,已终止操作”
- 使用Javascript完成文件操作、添加新项到HTML控件SELECT中、读取SELECT控件中的选定项
- Windows Mobile下使用HTML控件
- asp.net mvc使用html对象创建控件
- MVC中使用HTML Helper类扩展HTML控件
- Windows Mobile下使用HTML控件
- aspx 下使用原生html 控件上传文件的问题
- Flex中textArea控件,使用HTMLTEXT
- Windows Mobile下使用HTML控件
- 手机html页面对checkbox控件需要使用click事件,而不是tap
- 使用html控件中file field实现WEB上传
- html 控件作为服务器端控件使用的注意事项
- html,datepicker,datetimepicker时间控件使用