One of the elements on my webpage has the unique identifier last_name
. I am trying to extract its value and pass it to an input
tag.
My attempt at achieving this is shown below, but it does not work as intended.
<input type="hidden" name="lastName" value=document.getElementById("last_name").value>
Is there a method to accomplish this task?
This action is not just limited to page load.
To elaborate, I have multiple textboxes arranged together in a form.
Subsequently, I have another form containing a button. When the user clicks the button, I want the values of my input tags to be the current entries in the textboxes.
EDIT: My issue has been resolved! I had to eliminate the "value" attribute from the input tags, then include an "onclick" attribute to my button, and finally utilize the provided javascript codes to achieve the desired functionality.