Change field caption by jQuery

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
SOHIB
User
Posts: 93

Change field caption by jQuery

Post by SOHIB »

Hello all

i am tring to use this code to change the caption of one field conditionaly depends of the value of combobox but it is not working. is there any hints please
i put the code on startup script

$(document).ready(function() {
  // Attach change event handler to the combobox
  $("#b_name").change(function() {
	var selectedValue = $(this).val(); // Get the selected value

	// Conditionally change the label based on the selected value
	if ((selectedValue === "v1")||(selectedValue === "v2")) {
	  $("#myLabel").text("New Label Name");
	} 
  });
});

arbei
User
Posts: 9384

Post by arbei »

If "#b_name" is your own native <select> tag added by yourself (not an existing field in the table), then the id and the code to get the selected value are correct, otherwise it is wrong. But the id "myLabel" does not look like the id of a field caption. You better check the actual id or CSS selector for the field input and caption by inspecting HTML element in your browser.


SOHIB
User
Posts: 93

Post by SOHIB »

No the b_name is an existing field in the table and it define as dropdown list


arbei
User
Posts: 9384

Post by arbei »

Then the CSS selectors in your code are wrong.

arbei wrote:

You better check the actual id or CSS selector for the field input and caption by inspecting HTML element in your browser.


Post Reply