5

Ruby on Rails のテキスト フィールドにヒント テキスト (デフォルト テキストではない) を設定するための最良の方法を提案できますか? 現在、私はこれを使用しています:

<%= text_field_with_auto_complete
  "customer", 
  :contact_person, { 
    :value => 'last, first',
    :style => 'color:#aaa;width:11em;', 
    :onfocus => "if(this.getValue()=='last, first'){this.clear();this.style.color = '#000';}",
    :onblur => "if(this.getValue()==''){this.setValue('last, first');this.style.color = #aaa';}" 
  } %>

テキスト フィールドはモデルにアタッチされ、データベース内の値にアタッチされます。また、index.html で使用されているものと同じ html が edit.html でも使用されているため、フィールドを編集しようとすると、データベースの値ではなくデフォルト値が表示されます。これを行う正しい方法は何ですか?

注: デフォルト値を設定しようとしているのではなく、テキスト ボックスに何を入力する必要があるかについてのヒントです。

ありがとう、

ラジャ・ラム

4

2 に答える 2

2

このjqueryプラグインを試してください

http://plugins.jquery.com/project/hint

またはここで選択:

http://plugins.jquery.com/plugin-tags/hint

試作用

http://davidchambersdesign.com/autopopulating-input-fields-with-prototype/

于 2011-02-21T22:30:46.123 に答える