求救啊~关于<input type=text>输入框的问题 左面要一个下拉列表,3个选项aa bb cc ,然后一个<input type=text>输入框选择aa的时候 输入框中显示:优秀的选择bb的时候 输入框中显示:良好的选择cc的时候 l输入框中显示:及格的并且要求鼠标点击到输入框上,里面的字清空..谢谢大家啦!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <form><select onchange="this.form.b.value=this.value"><option value="优秀的">aa..</select><input name=b onfocus='this.value=""'></form> <form> <select onchange="this.form.b.value=this.value"><option value="优秀的">aa<option value="良好的">bb<option value="及格的">cc</select><input name=b onfocus='this.value=""'></form> <select id="sel1" onchange="showselect();"> <option value='优秀的' selected>aa</option> <option value='良好的' >bb</option> <option value='及格的' >cc</option></select><input id="txt" type="text" size="10" value="" /><script type="text/javascript"> function showselect(t) { var obj=document.getElementById("sel1"); var txt=document.getElementById("txt"); txt.value=obj.options[obj.selectedIndex].text; } document.getElementById("txt").onclick=function(){ this.value=""; };</script> <select id="sel1" onchange="showselect();"> <option value='优秀的' selected>aa</option> <option value='良好的' >bb</option> <option value='及格的' >cc</option></select><input id="txt" type="text" size="10" value="" /><script type="text/javascript"> function showselect(t) { var obj=document.getElementById("sel1"); var txt=document.getElementById("txt"); txt.value=obj.options[obj.selectedIndex].value; } document.getElementById("txt").onclick=function(){ this.value=""; };</script> 是这样的,这个下拉菜单,要求是用一个控件实现的,为了美观。代码如下:<combobox id="Type" width="85" frameWidth="83" labelposition="top" columns="1" groupClass="group" itemClass="item" itemOverClass="itemOver" itemSelectedClass="itemFocus" value="0"><tip position="frameTop"><div style="padding: 1px; width: 81px;"><table cellspacing="0" cellpadding="4" border="0" id="Type_Items" style="background-color: rgb(255, 255, 255); cursor: default; width: 79px;"><tbody><tr><td index="0,0" class="undefined" normalclass="undefined" overclass="undefined" selectedclass="undefined"/></tr><tr><td index="0,1" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">优秀的</td></tr><tr><td index="0,2" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">良好的</td></tr><tr><td index="0,3" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">及格的</td></tr></tbody></table></div></tip></combobox> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <style> body,td,div,input{font-weight:normal; font-size:11px; font-family:verdana; color:#000000;}</style> </HEAD> <script language="javascript" type="text/javascript">function chan(obj){var v=obj.options[obj.options.selectedIndex].value;var inbox=document.getElementById("txt");if(v=="aa") inbox.value="优秀的";else if(v=="bb") inbox.value="良好的";else inbox.value="及格的";}</script><BODY> <select id="select01" name="select01" onChange="javascript:chan(this);"> <option value="aa">aa</option> <option value="bb">bb</option> <option value="cc" selected>cc</option></select><p><input id="txt" name="txt" type="text" onClick="javascript:this.value='';"></p></BODY> </HTML> 改控件的一般不了解。你直接在相应DOM上加onclick等事件(代码)就行了 是这样的,这个下拉菜单,要求是用一个控件实现的,为了美观。代码如下: <combobox id="Type" width="85" frameWidth="83" labelposition="top" columns="1" groupClass="group" itemClass="item" itemOverClass="itemOver" itemSelectedClass="itemFocus" value="0"> <tip position="frameTop"> <div style="padding: 1px; width: 81px;"> <table cellspacing="0" cellpadding="4" border="0" id="Type_Items" style="background-color: rgb(255, 255, 255); cursor: default; width: 79px;"> <tbody> <tr> <td index="0,0" class="undefined" normalclass="undefined" overclass="undefined" selectedclass="undefined"/> </tr> <tr> <td index="0,1" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">优秀的 </td> </tr> <tr> <td index="0,2" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">良好的 </td> </tr> <tr> <td index="0,3" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">及格的 </td> </tr> </tbody> </table> </div> </tip> </combobox> <select name="sel" onchange="setValue(this);"> <option value="0">--choose--</option> <option value="aa">aa</option> <option value="bb">bb</option> <option value="cc">cc</option> </select> <input type="text" name="tex" id ='cont' onfocus="this.value=''">function setValue(obj){ //alert(obj.value); var textObj = document.getElementById('cont'); if(obj.value == 'aa'){ textObj.value='优秀'; } if(obj.value == 'bb'){ textObj.value='良好'; } if(obj.value == 'cc'){ textObj.value='及格'; } if(obj.value == '0'){ textObj.value=''; } } 我是楼主~!!是这样的,这个下拉菜单,要求是用一个控件实现的,为了美观。代码如下: <combobox id="Type" width="85" frameWidth="83" labelposition="top" columns="1" groupClass="group" itemClass="item" itemOverClass="itemOver" itemSelectedClass="itemFocus" value="0"> <tip position="frameTop"> <div style="padding: 1px; width: 81px;"> <table cellspacing="0" cellpadding="4" border="0" id="Type_Items" style="background-color: rgb(255, 255, 255); cursor: default; width: 79px;"> <tbody> <tr> <td index="0,0" class="undefined" normalclass="undefined" overclass="undefined" selectedclass="undefined"/> </tr> <tr> <td index="0,1" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">优秀的 </td> </tr> <tr> <td index="0,2" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">良好的 </td> </tr> <tr> <td index="0,3" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">及格的 </td> </tr> </tbody> </table> </div> </tip> </combobox> 你用的控件我们没用过,因此只能说个思路不可能帮你写对代码。<td index="0,3" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">及格的 </td>这类类型的DOM上面加上onclick的事件比如用Jquery找类似DOM并写入函数$("td[index='0,3']").click( function(){ document.formName.inputText.value = $(this).text();}); if(document.comboBoxes["Type"].hiddenField.value == '优秀的')这个属性是可以用的,就是不知道再往下要怎么写了.... js调用webservice 如何用脚本登陆需填写用户名和密码的网站? 请问JSP里怎样把javascript的变量值赋给java的变量,谢谢 javascript幻灯片效果被阻止? 怎么办? 【散分】Javascript 新年快乐(2),喜迎2010 javascript更换单元格背景图 新人求助~ 如何让页面延时显示 推荐几个javascript 的好网站吧! 如何做身份证验证函数100 分 怎样控制input的readonly属性? EXTJS 调用函数传参问题 100很 求一个JS 不难
<option value="优秀的">aa
..
</select>
<input name=b onfocus='this.value=""'>
</form>
<option value="优秀的">aa
<option value="良好的">bb
<option value="及格的">cc
</select>
<input name=b onfocus='this.value=""'>
</form>
<option value='优秀的' selected>aa</option>
<option value='良好的' >bb</option>
<option value='及格的' >cc</option>
</select>
<input id="txt" type="text" size="10" value="" />
<script type="text/javascript">
function showselect(t)
{
var obj=document.getElementById("sel1");
var txt=document.getElementById("txt");
txt.value=obj.options[obj.selectedIndex].text;
}
document.getElementById("txt").onclick=function(){
this.value="";
};
</script>
<option value='优秀的' selected>aa</option>
<option value='良好的' >bb</option>
<option value='及格的' >cc</option>
</select>
<input id="txt" type="text" size="10" value="" />
<script type="text/javascript">
function showselect(t)
{
var obj=document.getElementById("sel1");
var txt=document.getElementById("txt");
txt.value=obj.options[obj.selectedIndex].value;
}
document.getElementById("txt").onclick=function(){
this.value="";
};
</script>
<tip position="frameTop">
<div style="padding: 1px; width: 81px;"><table cellspacing="0" cellpadding="4" border="0" id="Type_Items" style="background-color: rgb(255, 255, 255); cursor: default; width: 79px;"><tbody><tr><td index="0,0" class="undefined" normalclass="undefined" overclass="undefined" selectedclass="undefined"/></tr><tr><td index="0,1" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">优秀的</td></tr><tr><td index="0,2" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">良好的</td></tr><tr><td index="0,3" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">及格的</td></tr></tbody></table></div>
</tip>
</combobox>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<style>
body,td,div,input{font-weight:normal; font-size:11px; font-family:verdana; color:#000000;}
</style>
</HEAD>
<script language="javascript" type="text/javascript">
function chan(obj)
{
var v=obj.options[obj.options.selectedIndex].value;
var inbox=document.getElementById("txt");
if(v=="aa")
inbox.value="优秀的";
else if(v=="bb")
inbox.value="良好的";
else
inbox.value="及格的";
}
</script>
<BODY>
<select id="select01" name="select01" onChange="javascript:chan(this);">
<option value="aa">aa</option>
<option value="bb">bb</option>
<option value="cc" selected>cc</option>
</select>
<p>
<input id="txt" name="txt" type="text" onClick="javascript:this.value='';">
</p>
</BODY>
</HTML>
<tip position="frameTop">
<div style="padding: 1px; width: 81px;"> <table cellspacing="0" cellpadding="4" border="0" id="Type_Items" style="background-color: rgb(255, 255, 255); cursor: default; width: 79px;"> <tbody> <tr> <td index="0,0" class="undefined" normalclass="undefined" overclass="undefined" selectedclass="undefined"/> </tr> <tr> <td index="0,1" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">优秀的 </td> </tr> <tr> <td index="0,2" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">良好的 </td> </tr> <tr> <td index="0,3" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">及格的 </td> </tr> </tbody> </table> </div>
</tip>
</combobox>
<select name="sel" onchange="setValue(this);">
<option value="0">--choose--</option>
<option value="aa">aa</option>
<option value="bb">bb</option>
<option value="cc">cc</option>
</select>
<input type="text" name="tex" id ='cont' onfocus="this.value=''">
function setValue(obj){
//alert(obj.value);
var textObj = document.getElementById('cont');
if(obj.value == 'aa'){
textObj.value='优秀';
}
if(obj.value == 'bb'){
textObj.value='良好';
}
if(obj.value == 'cc'){
textObj.value='及格';
}
if(obj.value == '0'){
textObj.value='';
}
}
<tip position="frameTop">
<div style="padding: 1px; width: 81px;"> <table cellspacing="0" cellpadding="4" border="0" id="Type_Items" style="background-color: rgb(255, 255, 255); cursor: default; width: 79px;"> <tbody> <tr> <td index="0,0" class="undefined" normalclass="undefined" overclass="undefined" selectedclass="undefined"/> </tr> <tr> <td index="0,1" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">优秀的 </td> </tr> <tr> <td index="0,2" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">良好的 </td> </tr> <tr> <td index="0,3" class="item" normalclass="item" overclass="itemOver" selectedclass="itemFocus">及格的 </td> </tr> </tbody> </table> </div>
</tip>
</combobox>
比如用Jquery找类似DOM并写入函数$("td[index='0,3']").click( function(){
document.formName.inputText.value = $(this).text();
});