Skip to main content
Inspiring
October 26, 2011
Answered

Passing variables via input/onclick

  • October 26, 2011
  • 3 replies
  • 1651 views

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?

    This topic has been closed for replies.
    Correct answer sockerdad

    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.

    3 replies

    sockerdadAuthorCorrect answer
    Inspiring
    October 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.

    Inspiring
    October 27, 2011

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

    Inspiring
    October 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.

    Participant
    October 27, 2011

    Hi,

    Rename the variable 'UserID' and try.

    Or clear your browser cookie and then try.