0

I want to login a website with javascript and i dont know it is allowed. I use javascript code in url and it gives me Invalid left-hand side in assignment at :1:10 error.

javascript:document.getElementById("OtherUsername")="myid";document.getElementById("OtherPassword")="mypassword";$("#btnSend").click();
1
  • you need to use value attribute document.getElementById("OtherUsername").value = "myuid", not sure what you are trying to do but you aremixing jquery n JS Commented Sep 26, 2017 at 5:37

2 Answers 2

1

As Vinod stated, you are trying to assign myid (a string) to document.getElementById("OtherUsername"), an object. That won't work. You need to assign it to document.getElementById("OtherUsername").value

This should work:

javascript:document.getElementById("OtherUsername").value="myid";document.getElementById("OtherPassword").value="mypassword";$("#btnSend").click();

The last bit $("#btnSend").click(); will only work if they have jQuery active on that site, or if you include it through use of a plugin somehow.

Sign up to request clarification or add additional context in comments.

Comments

1

you can not Assign a value to a dom element

if OtherUsername element and OtherPassword element is a form you can follow my code

document.getElementById("OtherUsername").value="myid";
document.getElementById("OtherPassword").value="mypassword";
$("#btnSend").submit(); //btnSend should be the from id

2 Comments

I was thinking i tried too but to be sure i tried again and it is happened , thanks
in the next time, ask javascript question with HTML code will be better

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.