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

Passing an identifier using hyperlink

Community Beginner ,
Oct 01, 2009 Oct 01, 2009

Hello;

I am at a loss. I fogot how to be able to pass a simple peramiter using a hyper link back to it's self on the same page. I also need the code that it activates only to activate if the link is used. How do I do this using a hyper link? I know how to use forms like this.

This is how the link works if I use another page to activate the code:

applysetting.cfm

<cfif IsDefined("deactivate")>
<cfcookie name="#deactivate#" value="Off" expires="never"><!--- <cookie defined - stop music> --->
<cflocation url="index.cfm" addtoken="no">
<cfelseif IsDefined("engage")>
<cfcookie name="#engage#" value="temp" expires="NOW"><!--- <cookie removed music is on> --->
<cflocation url="index.cfm" addtoken="no">
</cfif>

index.cfm

<a href="apply-setting.cfm?engage=hitbox">Sound On</a>

or

<a href="apply-setting.cfm?deactivate=hitbox"><strong><u>Sound Off</u></strong></a>

I am trying to make it work on one page:

index.cfm

<head>

<cfif IsDefined("deactivate")>
<cfcookie name="#deactivate#" value="Off" expires="never"><!--- <cookie defined - stop music> --->
<cfelseif IsDefined("engage")>
<cfcookie name="#engage#" value="temp" expires="NOW"><!--- <cookie removed music is on> --->
</cfif>

</head>

<body>

<a href="index.cfm?engage=hitbox">Sound On</a>

or

<a href="index.cfm?deactivate=hitbox"><strong><u>Sound Off</u></strong></a>

</body>

as it sits right now, it doesn't work properly.How can I adjust this so I can just make it load the one page and not the applysetting.cfm to make it work?

Thank you

1.2K
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 01, 2009 Oct 01, 2009

Look at the address bar of your browser for an example.

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
Community Beginner ,
Oct 02, 2009 Oct 02, 2009

So how owuld I write my if statement for activating the code using this? index.cfm?deactivate=hitbox that was copied from my url. It seems to fire to turn off my app, but not to turn it on.

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
Guest
Oct 02, 2009 Oct 02, 2009

Something very similar was discussed here:

http://forums.devshed.com/coldfusion-development-84/deleting-cookie-not-working-345115.html


(see end of post)

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
Community Beginner ,
Oct 03, 2009 Oct 03, 2009

I re-wrote the code similar to the link you posted. I still can't get this to go off properly. I believe I have this coded wrong.

Can anyone help me fix this so it will work properly?This is what I changed the code to:

<cfparam name="url.hitbox" default="" />

<cfswitch expression="#url.hitbox#">

<cfcase value="deactivate">
<cfcookie name="#deactivate#" value="Off" expires="never">
</cfcase>

<cfcase value="engage">
<cfcookie name="#engage#" value="temp" expires="NOW">
    <cfset structDelete(cookie,'hitbox') />
</cfcase>

</cfswitch>

<head>

</head>

<body>

<cfif IsDefined("cookie.hitbox")>

<a href="index.cfm?engage=hitbox">Sound On</a>

<cfelse>
<a href="index.cfm?deactivate=hitbox"><strong><u>Sound Off</u></strong></a>

</cfif>

</body>

Does anyone have any ideas?
Thank you

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
Contributor ,
Oct 03, 2009 Oct 03, 2009

I think you are trying something like this:

<cfparam name="url.hitbox" default="" />
<cfswitch expression="#url.hitbox#">
    <cfcase value="deactivate">
        <cfcookie name="hibox" value="Off" expires="never">
    </cfcase>
    <cfcase value="engage">
        <cfcookie name="hitbox" value="On" expires="now">
        <cfset structDelete(cookie,'hitbox') />
    </cfcase>
</cfswitch>
<cfif IsDefined("cookie.hitbox")>
    <a href="index.cfm?hitbox=engage">Sound On</a>
<cfelse>
    <a href="index.cfm?hitbox=deactivate"><strong><u>Sound Off</u></strong></a>
</cfif>

Ken Ford
Adobe Community Expert - Dreamweaver/ColdFusion
Adobe Certified Expert - Dreamweaver CS4
Adobe Certified Expert - ColdFusion 8
Fordwebs, LLC
http://www.fordwebs.com
http://www.cfnoob.com

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
Community Beginner ,
Oct 03, 2009 Oct 03, 2009

cool! It now turns off the music, but for some reason it is not turing it back on. I'll show you:

<!--- This part works! --->

<cfparam name="url.hitbox" default="" />
<cfswitch expression="#url.hitbox#">

<cfcase value="deactivate">
<cfcookie name="hitbox" value="Off" expires="never">
</cfcase>

<!--- this part does not --->

<cfcase value="engage">
<cfcookie name="hitbox" value="On" expires="now">
<cfset structDelete(cookie,'hitbox') />
</cfcase>

</cfswitch>

this is the link that doesn't work. Am I setting my cookie wrong?

<a href="index.cfm??hitbox=engage">Sound On</a>

<cfif IsDefined("cookie.hitbox")>

<cfelse>

working link

</cfif>

Can't figure out what I am doing wrong. I set a cookie that expires and then delete it. I'm confused

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
Contributor ,
Oct 03, 2009 Oct 03, 2009

How about just checking the value of the cookie?


<cfparam name="url.hitbox" default="" />
<cfparam name="cookie.hitbox" default="" />
<cfswitch expression="#url.hitbox#">
    <cfcase value="deactivate">
        <cfcookie name="hitbox" value="Off" expires="never">
    </cfcase>
    <cfcase value="engage">
        <cfcookie name="hitbox" value="On" expires="never">
    </cfcase>
    <cfdefaultcase>
        <cfcookie name="hitbox" value="Off" expires="never">
    </cfdefaultcase>
</cfswitch>
<cfif cookie.hitbox EQ "Off">
    <a href="index.cfm?hitbox=engage">Sound On</a>
<cfelse>
    <a href="index.cfm?hitbox=deactivate"><strong><u>Sound Off</u></strong></a>
</cfif>

Ken Ford

Message was edited by: Ken Ford - ACE

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
Community Beginner ,
Oct 03, 2009 Oct 03, 2009
LATEST

All fixed! Thank you!

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