At 09:38 AM 4/17/2002 -0500, you wrote:
Thanks for the reply. Our form will have inventory categories. Each one will
feature a text input box for quantity next to a select menu. The user will
be able to type a number quantity in a certain category, then select a
specific item from the drop-down select, then immediately see the
quantity/item appear on a temporary table on the same page as the web form.
Ok, In this case you seem to have three variables, and an output value based on the 2 variables selected 1)quantity
2)select box populated from a query
3)quantity/item variable dependant on what is selected
In this case I would strongly suggest using <CFWDDX> to automatically convert the query values to javascript and avoid using javascript tables and then trying to convert them back to CF variables. Using <CFWDDX> might sound intimitading at first but it does make life so much easier.
After using <CFWDDX> you're javascript programmer will be able to easily use the values selected using javascript to immediately show quantity/item.
I have used <CFWDDX> to populate 3 related select boxes dynamically before. I did it for someone on this forum, he was trying to populate city & county select boxes dynamiccaly from an access table( I added street to make it a better example). I will include the code at the bottom. Also for further information on using <CFWDDX> I would suggest reading through Nate Weiss' WDDX code in the two WDDX chapters in Ben Fortas advanced CF book.
Once a variety of these pairs has been established, they'll press the form
submit button, and the data in the table will pass to the CF template. We've
built some similar pages before, but the new wrinkle is the JavaScript table
where all user choices will be stored.
Avoid using javascript tables and trying to convert them back this is more a pain than anything else.
Finnaly you can email me for sample code and the access database if the below code is unclear,
Hope my reply helps,
p.s. this code works in both browsers
<html>
<head>
<title>States Counties and streets</title>
<cfquery name="States" datasource="StateCounty">
Select StateName, StateAbbr
From States
Order By StateName
</cfquery>
<CFQUERY NAME="StatesCounties" DATASOURCE="StateCounty">
SELECT CountyName, StateAbbr
FROM Counties
</CFQUERY>
<CFQUERY NAME="StreetsCounties" DATASOURCE="StateCounty">
SELECT CountyName, Streets
FROM Streets
</CFQUERY>
<script language="JavaScript">
<CFINCLUDE template='/CFIDE/scripts/wddx.js'>
// Convert the CF Query data into Javascript variables
<CFWDDX ACTION='cfml2js' input=#States# topLevelVariable='States'>
<CFWDDX ACTION='cfml2js' input=#StatesCounties# topLevelVariable='StatesCounties'>
<CFWDDX ACTION='cfml2js' input=#StreetsCounties# topLevelVariable='StreetsCounties'>
function ChangeCounties(selectedIndex,STAbbr, CountyNm) {
with (document.form){
CountyNm.length=0;
if (document.form.STAbbr.options[selectedIndex].value == StatesCounties.getField(row,'StateAbbr'))
{
// Load the dropdown list with counties for the state selected
CountyNm.options[ctr]=new Option(StatesCounties.getField(row,'CountyName'),StatesCounties.getField(row, 'CountyName'));
ctr++;
}
}
if ((document.form.CountyNm.options.length) == 0) {
ChangeStreets(document.form.CountyNm.selectedIndex,document.form.CountyNm,document.form.StreetNm);
return true;
}
}
function ChangeStreets(selectedIndex,CountyNm, StreetNm) {
with (document.form){
StreetNm.length=0;
if (document.form.CountyNm.options[selectedIndex].value == StreetsCounties.getField(row,'CountyName'))
{
// Load the dropdown list with counties for the state selected
StreetNm.options[ctr]=new Option(StreetsCounties.getField(row,'Streets'),StreetsCounties.getField(row, 'Streets'));
ctr++;
}
}
return true;
}
}
</script>
</head>
<body>
<cfform action="go.cfm" method="POST" enablecab="Yes" name="form" enctype="application/x-www-form-urlencoded">
<cfif not isdefined("form.started")>
<input type="hidden" name="started" value="yes">
</cfif>
<select name="STAbbr" ONCHANGE="ChangeCounties(document.form.STAbbr.selectedIndex,this.form.STAbbr,this.form.CountyNm,this.form.StreetNm)">
<option>Select State
<cfoutput query="States">
<option value="#States.StateAbbr#" >#States.StateName#
</cfoutput>
</select>
<select name="CountyNm" ONCHANGE="ChangeStreets(document.form.CountyNm.selectedIndex,this.form.CountyNm,this.form.StreetNm)">
<option>Select County
</select>
<select name="StreetNm">
<option>Select Street
</select>
<input type="submit" value="go">
</cfform>
</body>
</html>
We chose JavaScript to avoid the time
delay in submitting the form and then repeatedly coming back to the same
page to make additional choices within the categories. This project replaces
an older one that used VB and ran on the user's desktop.
Keith Purtell, Web/Network Administrator
VantageMed Operations (Kansas City)
Email: [EMAIL PROTECTED]
CONFIDENTIALITY NOTICE: This email message, including any attachments, is
for the sole use of the intended recipient(s) and may contain confidential
and privileged information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the intended recipient, please
contact the sender by reply email and destroy all copies of the original
message.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Richard Morrison
Sent: Wednesday, April 17, 2002 9:05 AM
To: [EMAIL PROTECTED]
Subject: Re: [KCFusion] Passing JavaScript variables to ColdFusion
In the case of form variables being manipulated with javascript I don't see
were there would be limitations, I've done this many times, anytime I used
to javascript to perform calculations or create other javascript variables
outside the form, I would set the calculated value to a hidden field inside
the form to make sure it got passed.
hope I was of help
p.s what kind of form are you trying to make?
At 08:28 AM 4/17/2002 -0500, you wrote:
We have a developer at one of our offices who is much quicker at building
JavaScripts than I am. We've asked him to help us build a particular type of
Web form where certain JavaScript variables will be set, which must then be
passed to a ColdFusion template. He has asked if there are any limitations
on what variables can be passed. I've done some tinkering with passing
simple values, but I'm concerned in this case that he is going to come up
with something I've never had to handle. Before I reply to his question, any
comments or tips?
Keith Purtell, Web/Network Administrator
VantageMed Operations (Kansas City)
Email: [EMAIL PROTECTED]
CONFIDENTIALITY NOTICE: This email message, including any attachments, is
for the sole use of the intended recipient(s) and may contain confidential
and privileged information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the intended recipient, please
contact the sender by reply email and destroy all copies of the original
message.
Richard Morrison
Cold Fusion Programmer (SDS),
Schlumberger
DRILLING SERVICES
P.O.Box 9261, Dubai. United Arab Emirates
Direct: 971 4 306 7127, Fax: 971 4 331 3614
Mobile: 971 50 62 10 869 .
=========================================================================
I understand that U.S. trade regulations prohibit certain transfers of U.S.
technology technical data or software to U.S. embargoed states.
I am aware of Schlumberger's Trade Control Policy and the OFS Export
Administration procedures with respect to U.S. embargoed states
and confirm that this transmission does not cause a prohibited transfer of
technology technical data or software.
=========================================================================
______________________________________________________________________
The KCFusion.org list and website is hosted by Humankind Systems, Inc.
List Archives........ http://www.mail-archive.com/cf-list@kcfusion.org
Questions, Comments or Glowing Praise.. mailto:[EMAIL PROTECTED]
To Subscribe.................... mailto:[EMAIL PROTECTED]
To Unsubscribe................ mailto:[EMAIL PROTECTED]
Cold Fusion Programmer (SDS),
Schlumberger
DRILLING SERVICES
P.O.Box 9261, Dubai. United Arab Emirates
Direct: 971 4 306 7127, Fax: 971 4 331 3614
Mobile: 971 50 62 10 869 .
=========================================================================
I understand that U.S. trade regulations prohibit certain transfers of U.S. technology technical data or software to U.S. embargoed states.
I am aware of Schlumberger's Trade Control Policy and the OFS Export Administration procedures with respect to U.S. embargoed states
and confirm that this transmission does not cause a prohibited transfer of technology technical data or software.
=========================================================================