dynamic action="#buildURL('action_URL')#"

249 views
Skip to first unread message

Jermy

unread,
Oct 19, 2010, 12:06:46 PM10/19/10
to framework-one
Hi List,

I am trying to use dynamic 'action_URL' in buildURL() function, I am
trying this with javascript--

<script language="javascript">
function changeFormAction(selectedLoginType)
{
var action_URL = '';
if (selectedLoginType == 'AppID')
action_URL = 'login.authenticate';
else
action_URL = 'login.authenticate';

document.frm_login.action = action_URL;
return true;
}
</script>

and form is--

<cfform name="frm_login" id="frm_login" method="post"
action="#buildURL('action_URL')#">
<cfinput type="radio" name="radio_login_type" value="AppID"
required="true" onclick="javascript:changeFormAction('AppID')"
checked="true"> Using Application ID <br>

<cfinput type="radio" name="radio_login_type" value="BellNTID"
required="true" onclick="javascript:changeFormAction('WindowID')">
Using Window ID <br>

Username: <cfinput type="text" name="username" required="true"
message="Enter your Username" /><br>
Password:<cfinput type="password" name="password" required="true"
message="Enter your Password" /><br>

<cfinput type="submit" name="submit" value="submit">
</cfform>


Any Suggestion?



Thanks in adv.
Jermy

Shane Pitts

unread,
Oct 19, 2010, 12:56:18 PM10/19/10
to framew...@googlegroups.com

Buildurl is a cf function that is parsed before the page is sent to the client. You can't call it from javascript.

> --
> FW/1 on RIAForge: http://fw1.riaforge.org/
>
> FW/1 on github: http://github.com/seancorfield/fw1
>
> FW/1 on Google Groups: http://groups.google.com/group/framework-one

Pete Freitag

unread,
Oct 19, 2010, 12:13:20 PM10/19/10
to framew...@googlegroups.com
Hi Jermy,

Keep in mind that ColdFusion runs server side and JavaScript runs client side, buildURL is a ColdFusion function, so you can't call it from javascript. An easy solution might just be to do this in your JS:

<cfoutput> action_URL = '#JSStringFormat(buildURL("login.authenticate"))#';</cfoutput>

--
Pete Freitag
http://foundeo.com/ - ColdFusion Consulting & Products
http://petefreitag.com/ - My Blog
http://hackmycf.com - Is your ColdFusion Server Secure?


Jermy

unread,
Oct 19, 2010, 1:32:07 PM10/19/10
to framework-one
Hi Pete,

same result :(
------------------------------------------------------------------------
Exception in onRequest
The action action_url.login failed.

Unable to find a view for 'action_url.login' action.
'auth/views/action_url/login.cfm' does not exist. (FW1.viewNotFound)
-------------------------------------------------------------------------


-Jermy


On Oct 19, 9:13 pm, Pete Freitag <pfrei...@gmail.com> wrote:
> Hi Jermy,
>
> Keep in mind that ColdFusion runs server side and JavaScript runs client
> side, buildURL is a ColdFusion function, so you can't call it from
> javascript. An easy solution might just be to do this in your JS:
>
> <cfoutput> action_URL = '#JSStringFormat(buildURL("login.authenticate"))#
> ';</cfoutput>
>
> --
> Pete Freitaghttp://foundeo.com/- ColdFusion Consulting & Productshttp://petefreitag.com/- My Bloghttp://hackmycf.com- Is your ColdFusion Server Secure?
> > FW/1 on Google Groups:http://groups.google.com/group/framework-one- Hide quoted text -
>
> - Show quoted text -

AJ Mercer

unread,
Oct 20, 2010, 11:04:39 AM10/20/10
to framew...@googlegroups.com
Javascript is executed on the bowser after the CFML has been processed - you have the two mixed up

Try moving BuildURL into the JavaScript
eg 
action_URL = '#buildURL("login.authenticate")#';

your else code also goes to login.authenticate - you probably don't want that

Set form action to default selected radio button
<cfform name="frm_login" id="frm_login" method="post"
action="#buildURL('login.authenticate')#">

onclick does not need javascript:
onclick="changeFormAction('WindowID')"


Any particular reason for having cfform and cfinput?


Reply all
Reply to author
Forward
0 new messages