0

私の仕事は、内部作業の送信に使用する非常に単純な Web フォームが必要です。提出された作品は、それぞれに必要な固有の情報を持つ 4 つのカテゴリに分類されます。現在、次のことを行う単純なフォームがあります。

依頼名:[テキストボックス]
依頼日:[テキストボックス]
取得方法:[テキストボックス]
依頼タイプ:[ドロップダウン] 4項目

私が望むのは、選択したドロップダウン項目に応じて、ユーザーが下に表示される正しいフォームを表示することです。これには、「入力用のアイテムとテキストボックス」を含むテーブルフォームが含まれます。

現在、これを試していますが、複数の問題があります。つまり、選択されているすべてのものではなく、1 つのテーブル行しか表示されません。

だから多分私は間違った方法で問題に取り組んでいますか?だから私はあなたの前に身を投げ出し、謙虚に助けを求めるつもりです。正しい方向へのポイント、またはこの時点での何か!

$(document).ready(function() {
   $('select[name="select_main_table"]').change(function() {
      $("#main_table tr").hide().eq(this.value-1).show();
   }).change();
});



      <td><label for="typeofrequest">Type of Request</label></td>
      <td><select name="select_main_table">
        <option value="" selected="selected"> - Choose -</option>
        <option value="1">Office Move</option>
        <option value="2">Office Closure</option>
        <option value="3">New Office</option>
        <option value="4">New Service</option>
      </select>          </td>
      <td>&nbsp;</td>
    </tr>

   <table id="main_table">
    <tr> 
      <td><label for="sitecontactname">Site Contact Name</label></td>
      <td><input type="text" class="validate[required,custom[sitecontactname]]" name="sitecontactname" id="sitecontactname" value="" /></td>
      <td>&nbsp;</td>
    </tr>

    <tr>  
      <td><label for="sitecontacttitle">Site Contact Title</label></td>
      <td><input type="text" class="validate[required,custom[sitecontacttitle]]" name="sitecontacttitle" id="sitecontacttitle" value="" /></td>
      <td>&nbsp;</td>
    </tr>

    <tr> 
      <td><label for="sitecontactemail">Site Contact Email</label></td>
      <td><input type="text" class="validate[required,custom[sitecontactemail]]" name="sitecontactemail" id="sitecontactemail" value="" /></td>
      <td>&nbsp;</td>
    </tr>

    <tr>  
      <td><label for="sitecontacttelephonenumber">Site Contact Telephone Number</label></td>
      <td><input type="text" class="validate[required,custom[sitecontacttelephonenumber]]" name="sitecontacttelephonenumber" id="sitecontacttelephonenumber" value="" /></td>
      <td>&nbsp;</td>
    </tr>
   </table>
4

1 に答える 1

0

お手伝いありがとう。別のサイトで、より良い解決策につながるコードを見つけることができました。

于 2013-01-10T13:42:39.577 に答える