How can I get a value from inside a function using Java script?

#1

here is the function from inside a script

> function dosubmit()
>   {
>     if (getObj("Frm_Username").value == "")
>     {
>       getObj("errmsg").innerHTML = "Username cannot be empty.";
>       getObj("myLayer").style.visibility = "visible" ;
>       return;
>     }
>     else
>     {
>       getObj("LoginId").disabled = true;
>       getObj("Frm_Logintoken").value = "3";
>       document.fLogin.submit();
>     }
>   }

i want to get the value of getObj("Frm_Logintoken") as i can’t pull the value from #Frm_Logintoken

using document.getElementById("#Frm_Logintoken") this gives me null

because Frm_Logintoken only gets it’s value when i click submit .

<input type="hidden" name="Frm_Logintoken" id="Frm_Logintoken" value="">

full page code

https://hastebin.com/tuhazuhipe.xml

tried document.getElementById("Frm_Logintoken"
too but it gives me <input type="hidden" name="Frm_Logintoken" id="Frm_Logintoken" value="">

i found this online
/getObj\("Frm_Logintoken"\).value = "(.*)";/g but when i run it … it gives me the same line again !
it’s full code

https://paste.ofcode.org/QLyguebhdPfRNeWUMjy273

How can I use a regular expression in JavaScript to get a value from page source code from a function tag?
How can I use a regular expression in JavaScript to get a value from page source code from a function tag?
#2
document.getElementById("Frm_Logintoken")

Route before id - jquery syntax only.

#3

image
what do you mean … what should i do with this ?

#4

Remove ‘#’ from your command.

#5

there is no # in my command
document.getElementById(“Frm_Logintoken”)

#6

and Frm_Logintoken only gets it’s value when i click submit

so the value is in

  getObj("Frm_Logintoken").value = "3";
#7

Ah… Sorry. That is in your post. I should to see your hastebin

#8

no prob

#9

Hi @minanageh379, if you set the value property on the element, the value attribute will remain the same and still be available via the defaultValue property. So if you want the attribute to reflect the property value, you can set either the defaultValue or use the setAttribute() method.

But this is normally not what you want; the default value should remain the same so you can for example reset the form. And the current value can be retrieved via the value property just like it got set, and is also the value that will get submitted with the form.

#10

so how can i get it ?
i don’t want to change it just get it !

#11

i just need to get the value

#12

hi would this help ? https://gist.github.com/ali-essam/80b58ea170051a96108b5f320754564f

#13
document.getElementById("Frm_Logintoken").value
#14

you are the number 100 that suggested me this !!!

it returns “”
emptyyyyyyyyyy cause Frm_Logintoken only gets it’s value when i click submit !!!

#16

This is probably because you are not setting that value anywhere but in the dosubmit() function. And the

if (getObj("Frm_Username").value == "") ...

check works as expected as well as far as user input is concerned.

#17

What you can do to get the value is to open your developer tools and watch for the network event when the submit occurs. You can then investigate that event to find out the values that were submitted.

#18

i am not the one who setts the value let me clear it to you
the Frm_Logintiken is a token generated by the page and it basically increment by one on each successful login!.

i want to make an auto login script !!

#19

why would i do that when i can just view them from the source code or inspect elements !

and i just want to make an auto login script !!

#20

So where is that token coming from, and where are you setting the input value to that token? Or do you expect the assigned value to persist across page loads (which it does not)?

Given your code, please explain the exact steps necessary to reproduce the problem, and at which point this differs from the expected result.