0

我需要使用相同的 javascript 函数填写工作的代码和姓名缩写。java脚本函数

<script type="text/javascript">
    function Expedisi(t) {
        var y = document.getElementById("code");
        y.value = t.value;
    }
</script>


<tr>
   <td width="200px" align="right"><label for=""><font color="0099FF"size="3px">Code</font><span></span></label></td>
   <td align="left"><input type="text" id="code"  name="code" value=" <?php echo ($addflag == 0) ? $get['loan'] : ""; ?>" class="form-input-code" readonly />
</tr>
<tr>
    <td width="200px" align="right"><label for=""><font color="0099FF" size="3px">Employee Name </font><span></span></label>
    </td>
    <td align="left"><select data-placeholder="Employee Name" style="width:332px;" id="cmbemployee" name="cmbemployee" class="chzn-select-deselect" onchange="Expedisi(this)""/>
        <option value="<?php echo ($addflag == 0) ? $gete['accode'] : ""; ?>"><?php echo ($addflag == 0) ? $gete['name'] : ""; ?></option>
        <?php
        $mown = mysql_query("SELECT * FROM accmast WHERE grpcode='044'") or die(mysql_error());
        while($trow = mysql_fetch_array($mown))
        {
          echo "<option value=$trow[accode]>$trow[name]</option>";
        }
        ?>
        </select>
    </td>
</tr>
4

2 回答 2

0

你无法在 js 中获取 select 元素的值!

<script type="text/javascript">
    function Expedisi(t) {
        var y = document.getElementById("code");
        y.value = t.options[t.selectedIndex].innerHTML
    }
</script>
于 2013-05-18T11:55:04.900 回答
0

在值周围放置单引号 ( '')。

while($trow = mysql_fetch_array($mown))
{
  echo "<option value='{$trow[accode]}'>{$trow[name]}</option>";
}
于 2013-05-18T12:01:18.507 回答