0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Salesforce】apex:repeatで表示している項目を取得して値も設定したい

Posted at

問題

apex:repeatで表示している項目を取得して値も設定したい

解決策

test.page

<apex:includeScript value="jqueryを読み込む" />

<apex:repeat value="{!testList}" var="test">
    <!-- html-data-idを設定する -->
    <apex:inputField value="{!test.test__c}" html-data-id="testid"/>
</apex:repeat>

<!-- 取得用ボタン -->
<button id="button" type="button">
    取得
</button>

<script>
    $('#button').on('click', function() {
        $("表示しているtableなどのID").find("input[data-id='testid']").each(function() {
            $(this).val('なにか設定したかったらここへ');
        });
    });

    // 表示しているtableなどのID = #tableid
    // apex:XXXXなどのtableなら = $Component.tableid
</script>

参考リンク

【jQuery】複数の要素に対して繰り返し処理をする(each・for)

Visualforce コンポーネントのカスタム HTML 属性の設定

【jQuery入門】find()で子要素を取得する手法まとめ!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?