You can use document.getElementsByTagName('classname')
<div>
<input type="text" class="textbox" /><br />
<input type="text" class="textbox" /><br />
<input type="text" class="textbox" /><br /><br />
<input type="button" value="Set Value" onclick="SetValue()" />
</div>
<script type="text/javascript">
function SetValue() {
var textboxes = document.getElementsByClassName("textbox");
//Set the First TextBox value.
textboxes[0].value = "Mudassar Khan";
//Set the Second TextBox value.
textboxes[1].value = "Maria Anders";
//Set the Third TextBox value.
textboxes[2].value = "John Wales";
};
</script>
Demo