Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Passing variables via input/onclick

Explorer ,
Oct 26, 2011 Oct 26, 2011

Here I am again!

I need to pass three fields via input/onclick.  The first is a constant, and the next two string variables.  I have to use input because the user wants a button to push.  This is a bummer because <a href works great.  It's that darn button!

Here's the code:

<input type="button" name="addnew" value="Add New Leave Request"

     onclick="location.href='index.cfm?fuseaction=add_new_leave&leave_id=A&user_id=#UserID#&user_name=#UserName#'">

I get to index.cfm, and to the correct fuse action.  But when I perform a dump of the URL at this point, all I get is:

leave_id           A

user_id            [empty string]

fuseaction        add_new_leave

No mention of user_name at all.  CFOUTPUT statements before the input statement indicate that UserID and UserName have valid values.  I figure the problem has to be with the way I am formatting the onclick clause, but just can't figure out what the problem is.

Any suggestions?

1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Oct 27, 2011 Oct 27, 2011

You're correct - the syntax is fine (The space after the 'A' was a typo here).  I tried the button image, but we don't have any cool tools here that create decent looking buttons - just Paint (shudder).

What did I forget?

To wrap the input statement in a cfoutput tag.

As soon as I did that, instant success.  Of all the crazy things, a simple cfoutput.

Translate
New Here ,
Oct 27, 2011 Oct 27, 2011

Hi,

Rename the variable 'UserID' and try.

Or clear your browser cookie and then try.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 27, 2011 Oct 27, 2011

Why not get an image of a button and put it in an anchor tag?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Oct 27, 2011 Oct 27, 2011

Well, there doesn't seem to be anything obviously wrong with your syntax (except for what looks like a space after the "A"):

A &user

If that doesn't fix the issue, dump out your URL scope on the index.cfm.  If your variables are showing up, then the issue is with fusebox not correctly passing your request variables on to the specified fuse.  Unfortunately, that is an area in which I can't help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 27, 2011 Oct 27, 2011
LATEST

You're correct - the syntax is fine (The space after the 'A' was a typo here).  I tried the button image, but we don't have any cool tools here that create decent looking buttons - just Paint (shudder).

What did I forget?

To wrap the input statement in a cfoutput tag.

As soon as I did that, instant success.  Of all the crazy things, a simple cfoutput.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources