I need to create a hash and put it in the placeholder for html input. I need the hash from the makehash()
function in the placeholder. I have tried to achieve this with the following code segment but am not getting the desired results.
placeholder: "string";
{% block javascript %}
<script>
function makehash() {
var hash = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < 5; i++)
hash += possible.charAt(Math.floor(Math.random() * possible.length));
return hash;
}
</script>
{% endblock %}
{% set attributes = {
guuid: {
class: option.class,
data_errortext: option.errortext,
id: key,
maxlength: 225,
name: name,
pattern: (option.pattern and option.pattern not in ['url', 'email']) ? option.pattern : '',
placeholder: hash should come here,
readonly: option.readonly,
required: option.required,
title: option.title,
type: (option.pattern in ['url', 'email']) ? option.pattern : 'text',
value: context.content.get(contentkey)|default(''),
}
} %}