-1

我有以下代码:

echo "<td><textarea wrap='soft' class=tarea3  name='inston[]'>".$r['inston']."</textarea></td>\n";

我想使用该inston变量与下拉列表相关联。我有下拉列表的工作代码:

  <tr><td class="tdt">

  <?php te('Hosting Server');?>:</td> <td title='Select server'>
   <select validate='required:true' class='mandatory' name='manufacturerid'>
   <option value=''>Select</option>
  <?php 
    foreach ($agents5 as $a) {
      $dbid=$a['id'];
      $atype=$a['label']; $s="";
      if (isset($manufacturerid) && $manufacturerid==$a['id']) $s=" SELECTED ";
      echo "<option $s value='$dbid' title='$dbid'>$atype</option>\n";
    }
    echo "</select>\n";
  ?>


  </td></tr>

以及对上述下拉脚本的 sql 查询,

$sql="SELECT * FROM items where itemtypeid=32 OR itemtypeid=44 order by label";
$sth=db_execute($dbh,$sql);
while ($r=$sth->fetch(PDO::FETCH_ASSOC)) $agents5[$r['id']]=$r;

我们如何使用上面的代码来关联inston变量?

4

1 回答 1

1

Your question isn't clear and from what i understood, is suppose the answer to be this

First of all , use an id for the select tag and textarea and use an onChange function like this:

<textarea wrap='soft' class=tarea3  name='inston[]' id='inston'>".$r['inston']."</textarea>
<select validate='required:true' class='mandatory' name='manufacturerid' id='manufacturerid' onChange='setInston()'>

and the use this javascript function :

function setInston() {
  var x = document.getElementById("manufacturerid").value;
  document.getElementById("inston").innerHTML= x+"&#10;";
}
于 2013-10-15T15:02:47.930 回答