Hi I have used dynamic panel. this dynamic panel has share location button in it encoded inside html input field.
When user clicks on share location button i want to populate lat and long in the panels input field.
Location sharing is working fine but how to bind data with dynamic panel input fields.
Kindly help me with this.
Binding Lat, Long in Dynamic Panel Field
Answers approved by surveyjs Support
Hello,
It is better to avoid running JavaScript from survey HTML fields. Please let me suggest that you add a custom action (IAction) using the survey.onGetPanelFooterActions / survey.onGetPanelTitleActions events.
With this option, you can access a panel object and set get panel fields using the panel.getQuestionByName function. Use the question.value to set a question's value. Please consider the following demo: View CodeSandbox.
JavaScriptsurvey.onGetPanelFooterActions.add((sender, options) => {
const panel = options.panel;
options.actions.push({
id: "sv-fill-panel-values",
title: "Set Values",
action: () => {
panel.getQuestionByName("question2").value = "test";
},
css: "nav-button",
innerCss: "sd-btn nav-input"
});
});
Please let me know if you have any further question.
P.S. We hope you enjoyed the level of service you received. If so, we would love if you could leave your feedback on SurveyJS page at g2.com. As we’re building our business, every review helps build credibility for future customers and your feedback would be greatly appreciated.