ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 11th, 2011, 05:24 AM
Newcf Newcf is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 14 Newcf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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,

Reply With Quote
  #2  
Old November 11th, 2011, 09:01 PM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,100 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 4 h 29 m 54 sec
Reputation Power: 966
I'm here to help but for something like this please at least do a Google search before you post.

http://stackoverflow.com/questions/...sing-javascript

Reply With Quote
  #3  
Old November 13th, 2011, 10:33 PM
Newcf Newcf is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 14 Newcf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 32 m
Reputation Power: 0
Hi Kiteless,
Thanks for the reply. I think you dint get my question. I was able to get the value of dropdown selected. But in the coldfusion I was not able to assign that value to my hidden variable.

<input type="hidden" name="h1" id="h1" value= "">
<cfif isdefined("form.h1")>
{
<cfoutput>Hidden var is #FORM.h1#</cfoutput>
}

Thank you

Reply With Quote
  #4  
Old November 14th, 2011, 01:42 AM
kiteless kiteless is offline
Moderator
Dev Shed God (5000 - 5499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 5,100 kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level)kiteless User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 2 Weeks 5 Days 4 h 29 m 54 sec
Reputation Power: 966
Sorry, I thought you were asking how to actually get the value from the select box. Changing the value on the page won't affect the CFML because the CFML was already executed on the server. You can't pass values from JavaScript to CF this way. JavaScript runs in the browser, and CFML runs on the server. The only way to make the server aware of the change and have your cfif execute again is to initiate another HTTP request by submitting the form.

Reply With Quote
  #5  
Old November 15th, 2011, 11:15 PM
Newcf Newcf is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 14 Newcf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 32 m
Reputation Power: 0
Hey Thanks...actually yea i the value was correctly set to the hidden variable. i was able to retrieve the value in the next page

Thanks for your patience and help

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Form variable undefined

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap