document.getElementById(formId)
form.querySelector('input[name="UserId"]')
hiddenInput.value
getUserId
form1
form2
function getUserId(formId) { // Get the form element by ID var form = document.getElementById(formId); // Find the hidden input with name="UserId" inside the form var hiddenInput = form.querySelector('input[name="UserId"]'); // Get the value of the hidden input if (hiddenInput) { var userId = hiddenInput.value; console.log("UserId:", userId); // Do something with the UserId alert("UserId: " + userId); } else { console.error("No hidden input with name='UserId' found in form with ID:", formId); } }
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: