javascript - Auto type from input to textarea and wrap text in textarea? -
while typing in input field:
<fieldset class="usp-title"> <label for="user-submitted-title"><?php esc_html_e('search', 'usp'); ?></label> <input id="user-submitted-title" name="user-submitted-title" type="text" value="" placeholder="<?php esc_attr_e('search', 'usp'); ?>"<?php if (usp_check_required('usp_title')) echo $usp_required; ?> class="usp-input"> </fieldset> i want automaticly type in field, text in here should sorrounded tags:
<fieldset class="usp-content"> <?php if ($usp_options['usp_richtext_editor'] == true) { ?> <div class="usp_text-editor"> <?php $usp_rte_settings = array( 'wpautop' => true, // enable rich text editor 'media_buttons' => true, // enable add media button 'textarea_name' => 'user-submitted-content', // name 'textarea_rows' => '10', // number of textarea rows 'tabindex' => '', // tabindex 'editor_css' => '', // css 'editor_class' => 'usp-rich-textarea', // class 'teeny' => false, // output minimal editor config 'dfw' => false, // replace fullscreen dfw 'tinymce' => true, // enable tinymce 'quicktags' => true, // enable quicktags 'drag_drop_upload' => true, // enable drag-drop ); $usp_rte_settings = apply_filters('usp_editor_settings', $usp_rte_settings); $usp_editor_content = apply_filters('usp_editor_content', ''); wp_editor($usp_editor_content, 'uspcontent', $usp_rte_settings); ?> </div> <?php } else { ?> <label for="user-submitted-content"><?php esc_html_e('post content', 'usp'); ?></label> <textarea id="user-submitted-content" name="user-submitted-content" rows="5" placeholder="<?php esc_attr_e('post content', 'usp'); ?>"<?php if (usp_check_required('usp_content')) echo $usp_required; ?> class="usp-textarea"></textarea> <?php } ?> </fieldset> second field should text sorrounded [bbcode]copied input[bbcode]
// when user types letter $("#user-submitted-title").keyup(function(){ // grab value, append tags , drop textarea $("#user-submitted-content").val("[bbcode]"+$(this).val()+"[bbcode]"); });
Comments
Post a Comment