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

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

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


Route before id - jquery syntax only.

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

Remove ‘#’ from your command.

there is no # in my command

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

so the value is in

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

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

no prob

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.

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

i just need to get the value

hi would this help ?


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

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

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.

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.

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 !!

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 !!

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.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.