I'm not completely clear on what you're trying to do, but it sounds like you
need the JavaScript "eval" function.
You can use syntax like:
function myFunction(someString){
var myWkDt;
var myArrive;
var myDepart;
myWkDt = eval('document.myForm.WkDt' + someString);
myArrive = eval('document.myForm.arrive' + someString);
myDepart = eval('document.myForm.depart' + someString);
This gives you objects you can then access for validation, etc.
(In your initial attempts, use several alert statements to verify you are
accessing the correct object: alert(myWkDt.value), for example.)
Show us some more sample code, also.
-----Original Message-----
From: Hays, Duncan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 26, 2000 12:21 PM
To: CF-Talk
Subject: Need help passing parameters to JavaScript
I'm trying to pass several parameters to JavaScript in an onChange event.
The input fields these are coming from are created in a loop. (This is for a
timesheet.) I'm able to make the names unique by using name="WkDt#i#. I'd
like to do something similar with the JavaScript parameters. I can get it to
work if I type all the parameters in like:
document.ts.WkDt#i#,document.ts.Arrive#i#,document.ts.Depart#i#,
etc...
But I'd like to set up a variable that I can put into the JavaScript call
because I have 15+ rows where I want to do this and 18+ parameters. And I
want be able to easily add more later. I've tried creating a variable and
putting Evaluate into it but the closest I can come is to have all
parameters passed where the #i# turns into 80. Here's a small portion of the
code.
<cfset vJSP =
"Evaluate(document.ts.WkDt#i#.value,document.ts.Arrive#i#.value,...)>
<cfloop index="i" from="1" to="14">
<cfoutput>
<tr>
<td><input type="text" name="WkDt#i#" value="#WkDt#"></td>
<td><input type="text" name="Arrive#i#" value="#Arrive#"
onChange="javascript:tsCalc#i#(this,#vJSP#")"></td>
</tr>
</cfoutput>
</cfloop>
Thanks
Duncan Hays
Peace Corps
----------------------------------------------------------------------------
--------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a
message with 'unsubscribe' in the body to [EMAIL PROTECTED]
------------------------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists or send a message
with 'unsubscribe' in the body to [EMAIL PROTECTED]