Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get attribute value of hidden form element

I´m using Postman to automate some tests. I need to get the value of the value attribute on the hidden field with the name "execution":

<form class="app-form" method="post" id="fm1" action="login" _lpchecked="1">
    <input type="hidden" name="execution" value="633ffc0f">
</form>

In postman, there´s only cheerio available for this. I´ve tried variations of the following, but none is working:

$('input#execution').attr("value");
$('input[name=execution]').attr("value");
$('input[type=hidden]').attr("value");
$(':hidden#execution').attr("value");
$('input:hidden[name=execution]').attr("value");

Many thanks!

like image 458
Christian Baumann Avatar asked Sep 12 '25 20:09

Christian Baumann


2 Answers

input[name=execution] does work fine for me

console.log($('input[type=hidden]').attr("value"));
console.log($('input[type=hidden]').val());
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<form class="app-form" method="post" id="fm1" action="login" _lpchecked="1">
    <input type="hidden" name="execution" value="633ffc0f">
</form>
like image 165
Nesewebel Avatar answered Sep 14 '25 10:09

Nesewebel


This is how you get value

const executionValue = $('input[name="execution"]').val();
console.log(executionValue);

https://jsfiddle.net/chille1987/3dap9yk4/2/

like image 24
Denis Omerovic Avatar answered Sep 14 '25 08:09

Denis Omerovic