Form variable undefined

I am new to coldfusion and i am trying out a sample cfm page. I have a dropdown where in i have 3 values say 1,2,3. Onchange of the dropdown, i need to set a hidden variable with the changed dropdown value. I am able to alert the dropdown value in javascript but not able to assign that value to the hidden variable. Please assist me.
My Sample code is as below:

<script language=“javascript”>
function loadHiddenvar()
alert(“inside fn”);
var ddVal=document.getElementById(‘dd1’).value;
<form name=“test” id=“test”>
DD1: <select name=“dd1” id=“dd1” onchange=“loadHiddenvar();”>
<option value=1>first</option>
<option value=2>second</option>
<option value=3>third</option>
<input type=“hidden” name=“h1” id=“h1” value= “”>
<cfif isdefined(“form.h1”)>
<cfoutput>Hidden var is #FORM.h1#</cfoutput>
Its always giving me variable h1 undefined.
I tried assigning this to a new variable and putting that as the hidden variable value. But that also didn’t work out
<cfset a=“#form.h1#”>
<input type=“hidden” name=“h1” id=“h1” value= #a#>
What is that I am missng here?

Thanks in advance,

You need to declare the variables you’re using. I know, it’s silly. At the top of your page, put this:

<cfparam name="FORM.h1" default="">

You’ll probably have to do it for your #a# too (but don’t include the ##s in the cfparam tag name)