My form has 3 images to be uploaded...more often then not the 3 images are named something like this image_S image_M image_L

so i was writing a function to auto fill the _M and _L once i selected the _S image.

here is my function

function auto_images() {
	input_box=confirm("Auto-fill _MD and _LG images??");
	if (input_box==true){ 
		// Output when OK is clicked
		var SM = document.forms.form1.product_image_sm.value;
			var MD_a = SM.split('_S.');
			var MD = MD_a.join('_M.');
			var LG_a = SM.split('_S.');
			var LG = LG_a.join('_L.');
			document.forms.form1.product_image_md.value = MD;
			document.forms.form1.product_image_lg.value = LG;
		// Output when Cancel is clicked
everything works except the part where I try to fill in the inputs value

document.forms.form1.product_image_md.value = MD;
does not work....can someone please advice the right way to do that?