
November 11th, 2011, 05:24 AM
|
|
Registered User
|
|
Join Date: Nov 2011
Posts: 14
Time spent in forums: 2 h 32 m
Reputation Power: 0
|
|
|
Form variable undefined
Hi,
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;
document.test.h1.value=ddVal;
alert(document.test.h1.value);
}
</script>
<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>
</select>
<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,
|