How do I set default values with JavaScript?

Hi Community,

I want to set a default value on a text field with JavaScript. The form has already been created and I don't want to use a ItemType for my project.

Can someone help me out?

Regards, David

Parents
  • Hi David,

    If you are not using an ItemType with this form, you could set a default value using either an onFormPopulated or onLoad event on your form. You would just need to look up the field in question, check to see if there is already a value set, and set your default value if it is not.

    You can take a look at this blog post to see how to get the input elements for your different fields. Rather than disabling them like the sample code in the blog post, you would just set the value attribute of your input. 

    Chris

Reply
  • Hi David,

    If you are not using an ItemType with this form, you could set a default value using either an onFormPopulated or onLoad event on your form. You would just need to look up the field in question, check to see if there is already a value set, and set your default value if it is not.

    You can take a look at this blog post to see how to get the input elements for your different fields. Rather than disabling them like the sample code in the blog post, you would just set the value attribute of your input. 

    Chris

Children