This topic is locked
[SOLVED]

Refreshing Event

6/9/2025 4:23:04 AM
PHPRunner General questions
A
anthonywalker author

Hi Guys,

I need to refresh a lookup field after a text field above it has been updated..

Any help would be appriciated.

Thanks
Anthony

ChatGPT 6/9/2025

Hi Anthony,

To refresh a lookup field in PHPRunner after a text field has been updated, you will typically need to use JavaScript. You can add an event listener to the text field that triggers when its value changes, and then refresh the lookup field accordingly.

Here’s a general approach to achieve this:

  1. Identify the Fields: Make sure you know the names or IDs of the text field and the lookup field you want to refresh.


  2. Add JavaScript: Go to the "Events" section in PHPRunner and add the following JavaScript code to the appropriate event (likely "OnChange" for the text field).



$(document).ready(function() {
// Replace 'text_field_id' with the ID of your text field
$('#text_field_id').on('change', function() {
// Perform the action to refresh the lookup field
// Replace 'lookup_field_id' with the ID of your lookup field
$('#lookup_field_id').select2('close'); // Close the select dropdown if using select2
$('#lookup_field_id').empty(); // Clear existing options

// Make an AJAX call to fetch new data for the lookup field
$.ajax({
url: "your_lookup_data_source.php", // Replace with your data source URL
method: "GET",
data: { query: $(this).val() }, // Send the value of the text field
success: function(data) {
// Assume 'data' is an array of options
$.each(data, function(index, item) {
$('#lookup_field_id').append($('<option>', {
value: item.value,
text: item.text
}));
});

// Re-initialize the select2 or any other dropdown if necessary
$('#lookup_field_id').select2();
}
});
});
});
  1. Data Source: Ensure that the URL in the AJAX call points to a script that can return the appropriate data for the lookup field based on the text field's input.


  2. Testing: After adding the JavaScript, test the functionality to ensure that the lookup field updates as expected when the text field is changed.



Make sure to adjust the IDs and URLs in the code to match your specific setup. If you have any further questions or need additional help, feel free to ask!

Best regards,
[Your Name]

Sergey Kornilov admin 6/9/2025

We covered this exact scenario in our latest DevClub webinar:
https://xlinesoft.com/devclub

A
anthonywalker author 6/9/2025

Hi Sergey,

Unfortunatly we dont have the budget for membership as we a not for profit sports shooting club.

Im building this signing in system free of charge for them.

Regards
Anthony

fhumanes 6/9/2025

Hi Antony.

I think what you need is in this article: https://fhumanes.com/blog/guias-desarrollo/guia-71-plugin-select2_ajax/

How it may be too complex for who does not have much programming experience, you can write to my email telling me in detail what you need and what version of Phprunner, and I make an example adjusted to your "problem."

Greetings,
fernando

A
anthonywalker author 6/12/2025

Hi Fernando,

Thank you for your reply, your solution seems very complicated, am I under estimating the amount of work involved in refreshing a lookup field after another has been updated?

Best regards
Anthony