I have a script in the "After Fields" section of the settings of a form. It's a form that is used by a registered user to edit their profile. I need to get some values from the form when a user opens it to edit their profile. Here is some code I am testing just to see if I can retrieve the user's entry values:
jQuery(document).ready(function ($) {
var parent = $("input[name='item_meta[622]']").val();
console.log("Value of parent/guardian field is " + parent);
var mail_list = $("input[name='item_meta[614]']").val();
console.log("Value of mailing list field is " + mail_list);
var user_acct = $("input[name='item_meta[921]']").val();
console.log("Value of user account field is " + user_acct);
var type = $("#field_sk5w3").val();
console.log("Value of type field is " + type);
});
All radio button fields are yes/no fields. The value for the first two fields in my test entry is "No" and the third one is "Yes". But they all are reported by the script as having "Yes" values. The text field reports the correct text value. What am I doing wrong?
Thanks Victor! I had tried that before but must have had the syntax wrong or it was a caching issue or something. This works: var parent = $("input[name='item_meta[622]']:checked").val();
Say, is there a way to use keys for this instead of IDs? I know how to do it in PHP but not JQuery/JS.
Yes, you can use $("[id^=field_mykey]:checked").val()
Excellent!!
Please login or Register to submit your answer