I know there are many questions related to this and I wouldn’t post this unless I had exhausted all posts and information I could possible find. I have tried to approach this from many many different angles to make sure I am not doing something wrong but I can not find it.
to trouble shoot, I have tried the following:
- check to see if there is more than one of the same ID of the field I am trying to get the val() from
- getting the child element’s of the wrapper id
- renaming
- adding the code in-line
Nothing works and nothing seems incorrect.
When I add a hard-coded string to the variable I am outputting, I see the string, but not the value of the input field.
I have been at this for two full days and I am stumped. Any hints or possible direction I should be looking at would be great.
I am using the same concept as in this code in many other places on the site and they all work fine.
<script>
$(document).ready(function() {
$(document).on("click", '.addTaskNote', function() {
var uniquevalue = $(this).data('uniquevalue');
console.log(uniquevalue);
var inputext = $("#" + uniquevalue).val();
console.log(inputext);
});
});
</script>
<cfset makeUnique = createUUID()>
<div id="div#makeUnique#">
<!--- short task note to add. --->
<input type="text" id="#makeUnique#">
<button class="addTaskNote" data-uniquevalue="#makeUnique#">UPDATE</button>
</div>
I know the function is triggered because the uniquevalue variable is logged to the console but the inputext variable is empty.
When I add a value attribute to the input field I still get an empty value.
<input type="text" id="#makeUnique#" value=""> returns empty
When I add a value to the value attribute, the console prints that value, but not any additional text I input.
<input type="text" id="#makeUnique#" value="hello"> returns ‘hello’ but when I type ‘there’ after ‘hello’ in the input field in the browser and click, it still only returns ‘hello’
Both the Javascript and the page code are part of a larger code file. When I create a separate file with this functionality it behaves as expected.
This I believe is where there might be an issue. I have looked for duplicate IDs, I have hardcoded the parameters and values to make sure there are no duplicates but this does not run as expected inside my code.
I believe this code is correct but there is a larger issue that I am not seeing and I don’t know where to begin looking. Any help or suggestions would be appreciated.

