Understanding field syntax with JavaScript and jQuery
Power Pages use a different syntax for interacting with different types of fields in forms. Whether you’re working with a text field, date field, choice field, or reference lookup field, understanding the correct syntax is essential for performing operations such as setting or retrieving values.
In the following examples, Sarah will explore the different syntax for a variety of field types and learn how to set or retrieve their values.
String field
Here is the syntax for retrieving the value for a String
field:
var description = $("imc_description").val();
This is how to set a value for this field:
$("imc_description").val("Fire on site");
Number field
Here is the syntax for retrieving the value for a Number
field:
var numberexample = $("new_numberfield").val();
This is how to set a value for this field:
$("new_numberfield ").val(10);