Q
Q
qiGuar2013-12-18 15:05:40
JavaScript
qiGuar, 2013-12-18 15:05:40

How to get a dynamically generated field with javascript?

I am writing a program in java.
I am sending a GET request. In response, a page comes with js. This page has a form. In firebug it looks like this

<form class="important" method="post" action="/do">
    <button class="important" type="submit">do</button>
    <input type="hidden" value="123" name="abc">
</form>

The hidden field is generated by javascript. It is not in the page source. The field value is present in the POST request when the form is submitted.
How or with what tools can you get the value of this hidden field?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
C
callback, 2013-12-18
@qiGuar

It is possible that javascript does not generate the field value itself, but receives it over the network. Look in firebug on the "network" tab for the value of this field. Don't forget to check the box "response content". If you find it, look at the query parameters and reproduce it in your program.

R
Rsa97, 2013-12-18
@Rsa97

For pure JS

var els = document.getElementsByName('abc');
var val = els[0].value;

For jQuery
:-( Didn't enter the question right away :-(
If you get a page in your program, then you need to analyze which scripts are executed on it and which one creates this field. Then look from which source data and according to what rules the value is formed fields in the script and also calculate this value in your program.

P
Petrusha Ukropov, 2013-12-18
@artishok

Hidden field - this is the same field, only it is not visible.
You can get it like this $field = $_POST['abc']; the main thing is not to forget about safety

M
maxaon, 2013-12-18
@maxaon

See if there are any WebSocket connections. Try adding a change handler and look at the call stack.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question