You don't always need to use id or name.
You could use xPath to retrieve elements using text of element -
//input[contains(text(),'sometext')]
or can also use Document Object Model (DOM) for same -
document.findElementsByTagName[0].click()
Both of these can be used by Selenium to exercise elements.
It would help answering if you post short version html of your application.
~ seleniumtests.com