Click here to Skip to main content
15,861,125 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am looking to make a log in form that enters the text that you type in the email and password and then press enter on the log in button. The problem I had the log in button doesn't have an ID for me to use GetElementById. Here is a screenshot of inspect element screen.

http://gyazo.com/3c30fcafe5a55ff42f2f9b809f65a3cf[^]
Posted

1 solution

The add the ID! Or do you expect it will be added by itself? :-)

[EDIT]

Thank you for clarification.

Please see my comments below.

You do not have to fill in the form, it won't give you anything. And id won't help you at all. You need to send HTTP request the way the form does. To do that, you need to use System.Net.HttpWebRequest:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.aspx[^].

Basically, the records of the HTTP request data block are identified by the attributes name of the form input elements, not id. You need to either lean some basics of HTTP or spy on what client does using some TCP/IP spy software.

—SA
 
Share this answer
 
v2
Comments
Zack McIntosh 11-Feb-13 12:14pm    
I didn't make the website so how can I add an id to the button?
Sergey Alexandrovich Kryukov 11-Feb-13 12:40pm    
OK, it's not yours? From your question, it wasn't clear at all. Normally, if you need id, you generated it, how else?
In this case, why would you need ID? I don't know your goals now, but if this is some kind of Web scraping, no matter how you do it, you would need to parse HTML. You always should start your questions with explanation of your ultimate goals. If you do, you might get further help...
—SA
Zack McIntosh 11-Feb-13 12:52pm    
My ultimate goal is to be able to log in from the form instead of having to log in at the website. It's as simple as that. I already have the code to enter the text from the form's textboxes to the webbrowsers1's textboxes but I can't do the button since it has no ID. If I were able to edit the HTML, how could I ad an ID? Just go to it and add id="somecrap" ?
Sergey Alexandrovich Kryukov 11-Feb-13 14:37pm    
Understood. You can do it, but the approach should be totally different. ID cannot help you, ever. You need to do completely different thing. You don't need to do anything with the form. Form merely sends HTTP request. You should send exact same form of HTTP request. The problem cannot be solved for all possible forms. You should look at a particular form and see what it does. Don't try to feel in the form.
Send HTTP request.
—SA
Zack McIntosh 11-Feb-13 18:02pm    
I appreciate you taking the time to help me on this. I still have quite figured out the entire thing but I did make a web browser that puts the webrequest in and as for where the line is it has this div

[spoiler]
<div>
<input name="commit" type="submit" value="Login" /> or

Create Account ·
Forgot Password?
</div>[/spoiler]

Here is some more of it:

<div class="bh_padding">
Sign in
</div>
</div>
</div>
<div class='content'>
<div class='left_image'></div>
<div class='right_image'></div>
<div class='mid_image'><div></div></div>
<div class='inner_content'>
<div class="bc_padding">

<div class='message'>


<form accept-charset="UTF-8" action="/users/sign_in" class="new_user" id="new_user" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="authenticity_token" type="hidden" value="iXZDAVAwPT35r4UVxKFTuodeZcMzvoyzwPpx+I17K24=" /></div>
<input id="return_to" name="return_to" type="hidden" />


<div>
<label for="user_email">Email</label>
<input id="user_email" name="user[email]" size="30" type="text" value="" />
</div>
<div>
<label for="user_password">Password</label>
<input id="user_password" name="user[password]" size="30" type="password" />
</div>
<div>
<input name="user[remember_me]" type="hidden" value="0" /><input id="user_remember_me" name="user[remember_me]" type="checkbox" value="1" /> <label class="checkbox" for="user_remember_me">Remember</label>
</div>
<div>
<input name="commit" type="submit" value="Login" /> or

Create Account ·
Forgot Password?
</div>
<div>

</div>
</form> </div>

</div>
</div>
</div>
<div class='footer'>
<div class='left_image'></div>
<div class='right_image'></div>
<div class='mid_image'><div></div></div>
<div class='inner_content'>
<div class="bf_padding">

</div>
</div>
</div>
</div>

</div>

</div>
</div>


<div>
Guild Hosting by Shivtr.

<span style='margin: 0px 4px;'>All Rights Reserved.</span>
<span>Copyright © 2013 Shivtr.</span>
</div>
<div>
Help & Support -
Terms of Use -
Privacy Policy -
Legal
</div>



</div>
</div>
</body>
</html>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900