Is there a better way: Take data from a page, click Menu button for form, fill in part of form with data from previous page

I was hoping the menu button would allow you to take data on page with button over and fill in the form on the next page, but I don't see it.

I did a workaround with javascript that highlights the corresponding data in the dropdown and moves it to the top of the list. Would love it if there is a more natural way to do this or javascript that actually makes the selection in the dropdown.

Basically on this Unit Details page, I want to take the Unit Address (1137 C St) and populated the dropdown on the Add Petition form when I click Add Petition button.

Any thoughts?

See my javascript below screenshot.

//set global variable to track what unit's detail page we are on when clicking Add Petition
var currentUnitDetail;

//add click event handler to Add Petition button that records the Unit address for the current page
//Will then use the variable to put that unit at the top of the dropdown on the Add Petition Form for ease of selection by staff
$(document).on('knack-scene-render.scene_5', function(event, scene) {
console.log("load unit details page");
$('#view_128').on('click', 'a', function() {
//pick up value from bold heading at top of the page indicating what unit address this is
currentUnitDetail = ($('.kn-detail-body span h1 strong span').text());
});
});

//Move current unit to the top of the dropdown selection
$(document).on('knack-scene-render.scene_85', function(event, scene) {
console.log("in Add Petition = " + currentUnitDetail);
var unitIndex = $('.chzn-results>li:contains("' + currentUnitDetail + '")').index();
console.log(unitIndex);
$('.chzn-results li:eq(0)').removeClass('result-selected');
$('.chzn-results li:eq(' + unitIndex + ')').addClass('result-selected');
$('.chzn-results li:eq(' + unitIndex + ')').insertBefore($('.chzn-results li:eq(0)'));
});

Hi Tim,

Assuming the Petition object is connected to the Unit Object (man-to-one?) the Unit Address won't need selecting for the new record as it'll be present by the Knack form?

So if you set the Unit as read-only on the new Petition form it should display the correctly especially if you've built the new entry from from a Unit page.

Apologies if I'm missing something here.

There are other options for presetting the dropdown box (Form Vars, or setting it's id directly) but I'm not sure you have to.

Brad