站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Javascript 专题javascript检测。在回送

javascript检测。在回送

摘要: javascript检测。在回送
<textarea readonly style="border:none;font-family:Courier New;line-height:150%;width:760px;overflow-y:visible">

<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
Text="服务器1">
Height="144px" Width="280px" TextMode="MultiLine">
Height="96px" Width="248px">Label
<input style="Z-INDEX: 104; LEFT: 192px; POSITION: absolute; TOP: 192px" type="button"

Text="服务器2">
Width="208px" Height="88px">Label
runat="server" NavigateUrl="select_test.aspx">select_text
</form>
<script language="javascript">
function aa()
{
//用这个方法获取服务器端控件的数值。用DOM对页面上的元素操作
alert(document.getElementById('TextBox1').value+"---服务器控件数值");
//在让客户端代码触发回送事件。
alert("客户端触发事件");
document.getElementById('Button1').click();
}

</script>
</body>

private void Button1_Click(object sender, System.EventArgs e)
{
this.Label1.Text=this.TextBox1.Text;
this.Button2_Click(sender,e);//引发按扭2事件
}

private void Button2_Click(object sender, System.EventArgs e)
{
this.Label2.Text=this.TextBox1.Text;
}

-------------------------------------------------------------------------------------------------------------------------------

<script language=javascript>
function aa()
{
//alert(document.getElementById('ListBox1').value);//获得select第一个被选中的元素
//alert(document.getElementById('ListBox1').length)//获得多选框的总元素数目
//获得select里所有被选中的元素
for (var i=0;i {
if (document.getElementById('ListBox1').options(i).selected) //检测某一元素是否被选中
alert(document.getElementById('ListBox1').options(i).value);//获得某元素的数值
}
}

</script>

--------------------------------------------------------------------------------------------------------------------------------

<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
&nbsp;
Text="服务器" Width="0px"><input style="Z-INDEX: 102; LEFT: 128px; POSITION: absolute; TOP: 128px" onclick="aa()"

Width="184px" Height="80px">Label<input id="aa1" style="Z-INDEX: 104; LEFT: 40px; POSITION: absolute; TOP: 72px" type="text">&nbsp;
Width="0px"> Width="272px" Height="144px"></form>
<script language="javascript">
function aa()
{
alert("客户端触发事件");
var aaaa=document.all.aa1.value; //获得客户端元素的数值
document.getElementById('TextBox1').value=aaaa; //把客户端元素的数值保留入服务器端元素内
//alert(document.getElementById('TextBox1').value);//显示服务器端元素的数值
document.getElementById('Button1').click();//使用脚本回送页面
}

</script>
</body>


</textarea>
↑返回目录
前一篇: javascript小技巧
后一篇: 一个Javascript链表