TextBox不会,但是select会,比如说我在js中将TextBox1的值设为468x60,此时select的值也是这个,提交以后select的值变回原来初始值(728x90),而TextBox1则仍保持为468x60,为什么会这样???------------------------------------ The textbox changes because it is a c# element on the web page.HTML elements will go back its default value when the page refreshs.But don't worry,the data it submited to server is the value you selected,not its default value.
<select id="test" onblur="onChange()" name="format">....
-----------------------------------------
function onChange(){
var e=event.srcElement;
document.getElementById("Label1").innerText = e.options(e.selectedIndex).value;
}
<select id="test" onblur="onChange()" name="format">
<optgroup label="横幅">
<option value="728x90" selected>728 x 90</option>
<option value="468x60">468 x 60</option>
<option value="234x60">234 x 60</option>
</optgroup>
<optgroup label="垂直">
<option value="120x600">120 x 600</option>
<option value="160x600">160 x 600</option>
<option value="120x240">120 x 240</option>
</optgroup>
<optgroup label="正方形">
<option value="125x125">125 x 125</option>
<option value="300x250">300 x 250</option>
<option value="250x250">250 x 250</option>
<option value="336x280">336 x 280</option>
<option value="180x150">180 x 150</option>
</optgroup></select>
-----------------------------------------
function func(a){
document.getElementById("Label1").innerText = a.options(a.selectedIndex).value;
}
<input type="hidden" id="hid">用hidden,取法和text一样
document.getElementById("Label1").innerText = a.options(a.selectedIndex).value;
document.getElementById("hid").innerText = a.options(a.selectedIndex).value;
}<input type="hidden" id="hid">
吃饭先,多谢各位回复!!!!!!!!!!
The textbox changes because it is a c# element on the web page.HTML elements will go back its default value when the page refreshs.But don't worry,the data it submited to server is the value you selected,not its default value.