JavaScript: How to change text value in an input box?

<form name='yourForm' action="">
     <input type='text' name='yourinput' id='yourinput' value='Hello World'>

<script type="text/javascript"> 
// Assign the value to the input with the id passed in 
function replaceInputValue( idRef, val ) { 
	// Make sure browser supports getElementById  
	if(!document.getElementById ) return; 
	// Find the input by it's id 
	var inputObj = document.getElementById( idRef ); 
	if( inputObj ) { 
	// Update the value 
	inputObj.value = val; 
replaceInputValue( 'yourinput', 'Hello Dolly' );