Forums

Javascript and field value

dimna 16 Sep, 2015
Hello,

I want to show the result of a javascript as default value in a text box.
If I put this in a custom field everything is displayed.
<SCRIPT>document.write(myFunction());</SCRIPT>
So the script is ok.
If I put this in as field value in a text box I only see the code as string…

How is it possible to save this value in a $form->data[value]? Perhaps with ajax?

Kind regards
Astrid
GreyHead 16 Sep, 2015
Hi Astrid,

Please try something like this in a Load JavaScript action to set the value of a text element:
jQuery(document).ready(function (jQ) {
  var result;
  result = myFunction();
  jQ('#id_of_text_element').val(result);
});

Bob
This topic is locked and no more replies can be posted.