Get value from form in javascript

Hi All

Complete beginner in Javascript here. How do I grab a value from the screen and use it in a script? It on a "details" screen

I want to set variable z to a scroll value on the screen (field 43)  

$(document).on('knack-scene-render.scene_11,view16', function(event, scene) {

var x = 1; //y-axis pixel displacement
var y = 1; //delay in milliseconds
var z = 5; //speed,,,I want to set this to field 43


setInterval(function() {
window.scroll(0, x);
x = x + z; //if you want to increase speed simply increase increment interval
}, y);

});

 

Thanks in advance

![](upload://7fVpNP95zhNusxLHMO5qlVDn3pP.png)

Hi Joanne, 

Knack has a global variable that isn't talked about or documented very well. 

To access a field from a details view you can write in your code: 

  • Knack.models[__insert-detail-view-key-as-string__].attributes.__insert-field-key__
  • Example: Knack.models.view_16.attributes.field_43_raw

To access records from a table view you can write this in code: 

  • Knack.models[__insert-table-view-key-as-string__].data.models.__insert-field-key__
  • Example: Knack.models.view_18.data.models.field_28_raw

If you still have further questions, feel free to reach out.

taylor@digitaloperatingsolutions.com