I’m using the Gravity Forms plugin for WordPress, and I’m trying to have one of the select menus dynamically update the text in a textarea. I’m very new to jQuery, and I’d really appreciate some help understanding how to make my code work.
<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>
(Code also at: http://pastie.org/pastes/5476003 )
input_27 â ID of the select menu.
input_20 â ID of the text area.
In short, I’d like the language in the textarea to change depending on which item they select from the dropdown.
Thanks in advance. 🙂
Please try this.
Please replace this code:
TO