Wait... hold on there... you're blaming ColdFusion when the real culprit here is Javascript.
Taking your example, when you code something like this in your HTML:
Code:
<cfoutput><textarea name="comment_#counterVariable#">#comments["#counterVariable#"]#<textarea></cfoutput>
ColdFusion intercepts the code before the browser ever sees it (intercepts it on the server-side), parses out all CFML and processes it (replacing #counterVariable# with the value of the variable counterVariable, performing any flow-control, etc, etc).
If you look at the HTML source (in your browser) for a CFM page once it's rendered, you'll see that there's absolutely no CFML left in it... it's all been turned into standard HTML so the browser will understand it. All of this is done
BEFORE the browser ever sees the page.
And since it's the
browser that interprets and processes javascript, javascript can't possibly run until after
all of the ColdFusion has completed (I suppose one could do something interesting with CFFLUSH... but that'd probably just turn into an unreliable mess).
So, to the browser, the above looks like:
Code:
>
<textarea name="comment_8">Hello world<textarea>
and when the form is submitted, the value of textarea comment_8 is, indeed, submitted just as if it were a standard value in a static form field (ie - the form submits "Hello world", not "comments["#counterVariable#"]"... the browser doesn't even know what comments["#counterVariable#"] is).
Now you can manually edit the text in the field, click submit, and ColdFusion can easily update the database with the new value (this is an extremely simple task in ColdFusion as well... I dare say simpler than doing it in ASP). But that wasn't the situation that you originally explained.
You said that you wanted to be able to somehow open a pop-up window, have the user check the appropriate checkboxes, close the window and have javascript take the results of what was checked in the pop-up and update the database or the variable name using ColdFusion. That's just not possible. In order for ColdFusion to update the database, it needs to be the first thing that processes (same with ASP)... and if it's the first thing that processes, your javascript variables would be empty (the javascript parser wouldn't even yet be active).
The
only way you can have javascript affect ColdFusion variables is to store the javascript values in a form field and submit the form... at which time ColdFusion can grab the values that are in the field (notice, I didn't say grab the javascript variables... they wouldn't exist anymore).
Now... you can do some tricky things, like include values of ColdFusion variables in your javascript... that might make it
seem like your ColdFusion can be manipulated by javascript. Something like:
Code:
function setElementValue(theID, theValue)
{
document.theID.value = theValue;
}
then, where you actually
call the function, you can wrap some CFML inside:
Code:
<cfset intendedValue = "hello">
<cfoutput><a href="javascript:void(0)" onclick="javascript:setElementValue(someElement,'#intendedValue#')">Change the value</a></cfoutput>
and now when you click on the link, the value of the element is set to the value of a ColdFusion variable... but in the end, it's all just HTML that's assembled on the fly.
There's no possible way that you'd be able to get something like:
Code:
function changingValues(id, valueReturned)
{
<cfset myColdFusionValue_id = valueReturned>
}
to work, because by the time changingValues() was called, myColdFusionValue_id would have already been set (and, in fact, the line "<cfset myColdFusionValue_id = valueReturned>" wouldn't even exist anymore.
Of course... you can also run javascript server-side... but server-side Javascript is not for the faint-hearted... and I don't believe it's capable of opening client-side pop-up windows, etc.
Hope it helps,
-Carl