Hi all, I am trying to create a token from user input on a html textarea. Unfortunately I can't use the default "input type=text" because I need to have a large text box for users to record investigations (which gets posted to an external ticketing tool). The idea is that the user completes the textbox and clicks on a "Next" or "Submit" button and the user input will be set as a token. The name of the token will need to be based on the id of the textarea as the dashboard may have a few textboxes. As a starter, I've been testing with the following and failing (not very good at Javascript): XML <form script="textarea.js">
<label>HTML Text Area Button</label>
<row>
<panel>
<html>
<textarea id="ta_investigateoutcome" rows="3"/>
<input id="html_ta_user_comment" type="button" value="Click"/>
<html encoded="1">TEST: $investigateoutcome$</html>
</html>
</panel>
</row>
<row>
<panel depends="$alwayshideCSSpanel$">
<html>
<style>
textarea {
width: 100%;
height: 150px;
padding: 12px 20px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
background-color: #f8f8f8;
resize: none;
}
</style>
</html>
</panel>
</row>
</form> textarea.js require([
'underscore',
'jquery',
'splunkjs/mvc',
'splunkjs/mvc/tableview',
'splunkjs/mvc/simplexml/ready!'
], function(_, $, mvc, TableView) {
var defaultTokenSpace = mvc.Components.getInstance('default');
$('textarea').parent().parent().addClass('textarea_div');
$('textarea').each(function (ta) {
$(this).on('click',"#html_ta_user_comment",function(input) {
defaultTokenSpace.set($(this).attr('id').replace('ta_' ,'') ,$(this).val());
})
})
});
... View more