Autofill username/password in HTMLViewer

I’d like to autofill forms in an HTMLViewer that ask for username and password. I’ve managed to come up with the javascript code that will let me inject the information, but you have to know the id of the fields (and this has to work on any old web site). Here’s an example that works with a particular web page asking for a pw

dim s as string = “mypassword”
dim script as string = “document.getElementById(‘edit-pass’).value = '”+ s +"’;"
me.ExecuteJavaScript(script)

My question is, is there a universal way to identify username and pw fields? Standalone browsers do it, so it must be possible, but it escapes me.