Time:
Scotland: Fri, 11:48 pm Rhode Island: Fri, 6:48 pm Florida: Fri, 6:48 pm New Mexico: Fri, 4:48 pm California: Fri, 3:48 pm
Buy this Ad Space. 180px wide. Please get in touch with KH@ if you are interested and make an offer.
US$10 per year - Save $100s! The Fabulously Unfair WebX Auction Bar. For Ebay etc. Ro-Sham-Bo the opposition. Laugh like Eric Cartman when you win! CLICK HERE NOW!More information and sign-up.
WebXpertz Hosting. Custom fit from $5pm. PHP/MySQL You'll save money, we'll save money. Seems fair to me. Interested? If so Please PM me here and tell me what you need. Thanks!
|
For continued disscussion on this topic : pass coldfusion variable to javascript?
oberon 09-26-2002, 08:06 AM is it possible to pass a coldfusion variable to be used in javascript?
I have tried the following
but not only doesn't it work but I get javascript error
<script language="JavaScript">
<!--
var oldvar = #BIN.pcdate#;
-->
</script>
thanks
piglet 09-26-2002, 02:03 PM I've never used CF - but I expect you just need some quotes unless BIN.pcdate is a number:
<script language="JavaScript">
<!--
var oldvar = "#BIN.pcdate#";
-->
</script>
oberon 09-27-2002, 03:33 AM BIN.pcdate is a date but putting either double or single quotes around it will all return javascript errors
Any other ideas?
thanks
piglet 09-27-2002, 10:23 AM Please can you post a copy of the generated javascript - or a link to the test page - it'll be easier to see what's going on in context.
Thanks
oberon 09-30-2002, 01:09 AM Heres what I am working on
http://67r761s/Quality/Bins/index.cfm
you'll need to log in to see what the error is
"ttrinh/password"
Thanks
Ulaire Smiley 09-30-2002, 01:21 AM It appears that you have a server installed on your computer, because the address you gave us is not a .com, .net, .org, etc. and we can't access it. Can you put it on the web?
- Smiley :)
oberon 09-30-2002, 01:36 AM Hi
Sorry I forgot I am behind a firewall and don't have access to our public site
Heres the part of code for the dropdown date :
<td valign="top" class="reqd">Planned Completion: </td>
<td valign="top">
<cfif BIN.pcdate neq "">
<cfset defaultdate = BIN.pcdate>
<cfelse>
<cfset defaultdate = "">
</cfif>
<cfif thisBIN.canEdit eq "false">
<cfset disabledflag = "yes">
<cfelse>
<cfset disabledflag = "no">
</cfif>
<cf_datedropdowns name="pcDate" startyear="1997"
endyear="2010" selected="#defaultdate#"
noneoption=" " dateformat="dd-mmm-yyyy"
show="no" class="reqdtext" disabled="#disabledflag#">
</td>
and heres my code for the checking for the date applied before someone hits the save button its in a dirfferent file:
<cfif thisBIN.canEdit eq "true">
<tr><td><img src="images/shim.gif" width="1" height="#buttonspace#" border="0"></td></tr>
<td> </td>
<cfif BIN.pcdate neq "">
<cfif BIN.pcdate neq #bin.pcdate#>
<td><input type="Button" value="Update;validate()" class="lhsbuttonsave" onclick="popup=window.open('changePCD.cfm?bin=#attributes.bin#','changePCDbox','width=350,height=190,scrollba rs=no,resizable=yes');self.focus();"></td>
<cfelse>
<td><input type="button" value="Save" class="lhsbuttonsave" onclick="validate(#BIN.pcdate#)"></td>
</cfif>
</tr>
</cfif>
<td>bin.pcdate: #bin.pcdate#<br>
BIN.pcdate : BIN.pcdate
<!-- <cfset olddate = #BIN.pcdate#>-->
</td>
<script language="JavaScript">
<!--
var oldvar = "#BIN.pcdate#";
-->
</script>
</cfif>
<script language = "JavaScript">
function validate(oldpcd){
//var oldpcd="";
var newpcd="";
if (oldpcd == newpcd){
alert("The pcdate has changed!");
return false;
}else document.submit();
}
</script>
thanks for looking at this.
Hi oberon, maybe//-->
</script>
( •) (• )
>>V
oberon 09-30-2002, 04:02 AM thanks Owl
tried that it didn't work tho
OnlyTheTony 09-30-2002, 04:18 PM I'm no Coldfusion person (PHP personally) but...
<cfif etc...>
<td>bin.pcdate: #bin.pcdate#<br>
BIN.pcdate : BIN.pcdate
<!-- <cfset olddate = #BIN.pcdate#>-->
</td>
<script language="JavaScript">
<!--
var oldvar = "#BIN.pcdate#";
-->
</script>
</cfif>
..is that not it??
(that's how I'd do it in PHP)
oberon 10-02-2002, 01:00 AM thanks OnlyTheTony but it didn't work :(
any other suggestions?
piglet 10-02-2002, 09:42 AM Please can you post a copy of the generated javascript
If we can see the output code (not the code as it appears on the server) we should be able to help.
If you bring up the page on your browser and do a view->source that's what we want to see!
NightHawk 10-04-2002, 05:28 PM Couple of things....
1.) Did you use <cfoutput> when you were displaying the variable?
<Cfoutput>
<script language="JavaScript">
<!--
var oldvar = #BIN.pcdate#;
-->
</script>
</cfoutput>
2.) Once the page has loaded, you can not pass ColdFusion variables to JavaSript. Coldfusion is a server side technology and javascript is a client side technology. In order for coldfusion to manipulate the contents of a javascript variable, you must somehow get the javascript variable back to the server so that a new coldfusion page can execute the variable.
HTH!
vBulletin® v3.6.4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.
|