WordPress の Gravity Forms プラグインを使用しており、選択メニューの 1 つにテキストエリア内のテキストを動的に更新させようとしています。私は jQuery に非常に慣れていないので、コードを機能させる方法を理解するのに役立つことを本当に感謝しています。
<script type="text/javascript">
$(document).ready(function() {
$('#input_27').change(function() {
var divetext = $('#input_27').val();
var divewords = '';
if (divetext == 'Standard') {
divewords = 'All Ye Surface Sailors, aviators, fossil-fuelers, landlubbers, and other innocents Know ye and Mark ye that from (date) to (date) the inner depths of my subaqueous realm were visited by a very large black denizen. On careful examination by my mermaids this great black fish was identified as (Name of submarine). I am informed that among the distinguished on board at that time was (Recipient name). By this my decree, this Submariner is awarded and shall bear in perpetuity the honored title of Deep Diver and shall be accorded all the perquisites and privileges that befit this exalted status.';
}
else if (divetext == '1st Dive') {
divewords = 'All Ye Surface Sailors, aviators, fossil-fuelers, landlubbers, and other innocents Know ye and Mark ye that from (date) to (date) the inner depths of my subaqueous realm were visited by a very large black denizen. On careful examination by my mermaids this great black fish was identified as (Name of submarine). I am informed that among the distinguished on board for their 1st Dive was (Recipient name). By this my decree, this Submariner is awarded and shall bear in perpetuity the honored title of Deep Diver and shall be accorded all the perquisites and privileges that befit this exalted status.';
}
else if (divetext == 'Last Dive') {
divewords = 'All Ye Surface Sailors, aviators, fossil-fuelers, landlubbers, and other innocents Know ye and Mark ye that from (date) to (date) the inner depths of my subaqueous realm were visited by a very large black denizen. On careful examination by my mermaids this great black fish was identified as (Name of submarine). I am informed that among the distinguished on board for their last time was (Recipient name). By this my decree, this Submariner is awarded and shall bear in perpetuity the honored title of Deep Diver and shall be accorded all the perquisites and privileges that befit this exalted status.';
}
else if (divetext == 'Honorary Submariner') {
divewords = 'All Ye Surface Sailors, aviators, fossil-fuelers, landlubbers, and other innocents Know ye and Mark ye that from (date) to (date) the inner depths of my subaqueous realm were visited by a very large black denizen. On careful examination by my mermaids this great black fish was identified as (Name of submarine). I am informed that among the distinguished on board at that time was (Recipient name). By this my decree, this Submariner is awarded and shall bear in perpetuity the honored title of Deep Diver and shall be accorded all the perquisites and privileges that befit this exalted status.';
}
else {
divewords = 'All Ye Surface Sailors, aviators, fossil-fuelers, landlubbers, and other innocents Know ye and Mark ye that from (date) to (date) the inner depths of my subaqueous realm were visited by a very large black denizen. On careful examination by my mermaids this great black fish was identified as (Name of submarine). I am informed that among the distinguished on board at that time was (Recipient name). By this my decree, this Submariner is awarded and shall bear in perpetuity the honored title of Deep Diver and shall be accorded all the perquisites and privileges that befit this exalted status.';
}
$("#input_20").val(divewords);
});
});
</script>
(コード: http://pastie.org/pastes/5476003 )
input_27 — 選択メニューの ID。input_20 — テキスト領域の ID。
要するに、ドロップダウンから選択したアイテムに応じて、テキストエリアの言語を変更したいと思います。
前もって感謝します。:)