jQuery をより多く使用するコードを修正して、この質問を再投稿しています。
オブジェクトを定義する HTML コードは次のとおりです。
<LEGEND><b>Select Study Sample</b></LEGEND>
<p>
<P CLASS=select_header>Study - Box - Well - Lab ID<br>
<SELECT multiple size=20 NAME="stylabid" ID="stylabid" onchange=show_stylabid() onclick=clear_fetch() STYLE="width: 115px">
<?php 
  $i=0;
  while ($i < $numstylabids) {
    $styarr = pg_fetch_row($stylabidresult);
    echo "<option value=$styarr[0]>$styarr[1]\n";
    $i++;           
  }
  ?>
</select>
と
<LEGEND><b>Select Project Sample</b></LEGEND>
<p>
<P CLASS=select_header>Project - Box - Well - Lab ID<br>
<SELECT multiple size=20 NAME="pjtlabid" ID="pjtlabid" onchange=show_pjtlabid() onclick=clear_fetch() STYLE="width: 115px">
<?php 
  $j=0;
  while ($j < $numpjtlabids) {
    $pjtarr = pg_fetch_row($pjtlabidresult);
    echo "<option value=$pjtarr[0]>$pjtarr[1]\n";
    $j++;           
  }
  ?>
</select>
さて、これがJavaScriptです。スタディまたはプロジェクトのいずれかである、選択したオブジェクトの値を取得しようとしています。後でこれを使用して、データベースからデータを取得します。
function fetchgenotype() {
    var ms, mndx, ss, sndex = 0;
    ms = $("#marker")[0].selectedIndex;    
    if (Study_selected) {
      ss = $("#stylabid")[0].selectedIndex;
      sndx = $("#stylabid").val(ss);
    } else
      ss = $("#pjtlabid")[0].selectedIndex;
      sndx = $("#pjtlabid").val(ss);
    }    
    // for debugging...    
 alert('ss='+ss+', sndx='+sndx);
このコードは行で死ぬsndx = ...  本当に助けていただければ幸いです!
ティア