cbfmai 发表于 2013-2-7 19:25:52

有关select中怎样得到labelProperty的值

今天第一次在javaeye中写文章,呵呵!!

问题:如主题,select中怎样得到labelProperty的值,再把得到的值放到一个文本框中:“principal”中。

下面是一个下拉框的代码:
<td>负责人:</td>    <td><html:text property="principal"styleClass="shorttext"/>      <html:select property="sysUser" onchange= "showBranch();">            <html:options collection= "user" property= "userid"       labelProperty= "uname" />         </html:select>    </td>

现在就想用JS 把 labelProperty的值得到!
用如下JS代码:

    // 得到负责人名称    function showBranch(){    // 得到文本对象    var checkObject=getElement("principal");    // 得到下拉框的 labelProperty 的值    var select = document.getElementById("sysUser");    var option = select.options;    checkObject.value = option.innerHTML;}

呵呵 以上就能动态地使文本框的值和下框的值一样了,这样就可以提交到后面拉!
页: [1]
查看完整版本: 有关select中怎样得到labelProperty的值