I'd like to add a parameter where variable topic_id = 16 to my url cfoutput query.

I have this SQL Table. Please see attached image.

I did a query in Coldfusion in order to retreive the topic name and it's working fine on the following page.

Now i'd like to refer to that query with my URL. It's working but it's not selectin topic one when i type the address. It's missing the variable parameter into my url.

http://127.0.0.1/jp/for/candidate_e.cfm

You can do it manualy, select 'topics' and topic one, so the page is displaying... but how i'm able to have the url point directly to topic 1.

SELECT id, topic_eng, topic_fr
	                                        FROM discForum_topics
                                        WHERE id = '#listRelationships.topic_id#'
                                        AND active = '1

Open in new window

topics.jpg
LelloLelloAsked:
Who is Participating?
 
micropc1Connect With a Mentor Commented:
ha...ignore my last comments... i found the answer in your own code...it looks like its already set up to respond to and use url parameters...

try this...

http://127.0.0.1/jp/for/candidate_e.cfm?action=true&&sortBy=2&xaction=true&response_id=75&topic_id=17&candidate_id=
0
 
micropc1Commented:
Its possible I'm misunderstanding the question, but what I think what you're saying is that you want to pass the topic_id as a URL parameter and not POST data when you select it from the drop-down, correct? something like http://127.0.0.1/jp/for/candidate_e.cfm?topic_id=1

You'll need to change your form method to "get"..

<form name="frmCandidate" method="get">

Open in new window


and access the variable from the URL scope instead of the FORM scope...

SELECT id, topic_eng, topic_fr
FROM discForum_topics
WHERE id = <cfqueryparam cfsqltype="cf_sql_integer" value="#URL.topic_id#">
AND active = '1

Open in new window

0
 
LelloLelloAuthor Commented:
Thank you for your reply... Did you understand my request... Did you click on that page and select topic ? then topic one.

Attached is the full code on that page. So what I should do? Please advice.
candidate-e-cfm.txt
0
Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

 
_agx_Commented:
(I'm not the person who 1st responded but ...)

      Did you click on that page and select topic ?

Yep

     Did you understand my request

Nope :)  Are you asking how to select those items by default the very 1st time the page loads?  If yes, sounds like you need to set default values at the very beginning of your page.

        <cfparam name="form.sortOptions" default="2"> <!--- topics --->
        <cfparam name="form.topic_id" default="16"> <!--- first topic id --->

Or you could use javascript to preselect the first non-empty list option.
0
 
TechHelpr08210Connect With a Mentor Commented:
Actually, this is the same answer as before.

You page is not setup to respond to url variables because all of the references are looking only in the form scope. To make your url reference work, you will need to convert url variables into the form scope automatically.

Also, this will only work if the form scope is empty (ie: if there isn't any form information being submitted.

Try putting this code at the top of your page.

Let me know how you made out.

<cfif structisempty(form)  > <cfset form = url /> </cfif>

Open in new window

0
 
_agx_Connect With a Mentor Commented:
Actually, this is the same answer as before.

I don't know about that.  The question isn't clear.  At least not to me. LelloLello  are you asking how to values in a URL in general OR how to select something by default the very 1st time the page loads.

<cfset form = url />

As mentioned on the other thread, that doesn't actually effect the system form scope, but a local variable instead.  IMO a safer method is to copy the variables into the system form scope, to avoid subtle bugs.
0
 
LelloLelloAuthor Commented:
Hello,

Please see attached printscreen, i'd like an URL address where i can go directly to topic1 and topic2.

I don't want to do any any changes to that pages http://127.0.0.1/jp/for/candidate_e.cfm. This is what on that page and it should work like that. But I need to insert a link on my others page where users can go directly to topic 1, or topic 2.

What I need is, I have another page and I'd like to create a link on that page.
For example:
To view topic 1, please click here. Which URL i should have for topic 1 http://127.0.0.1/jp/for/candidate_e.cfm?
To view topic 2, please clikc here. and which url i should have for topic 2. I want to go direct to that page.

How i can have my URL with paramater or variable topic_id equal 16.

I will attached the SQL Table for your review.
http://127.0.0.1/jp/for/candidate_e.cfm

Which code i'm missing. please view attached code above of my page.

thanks.
SQL-Tables.jpg
topic1.jpg
topic2.jpg
0
 
micropc1Commented:
You can't do it without making at least a simple change to candidate_e.cfm. Your simplest solution would be to move..

<cfset form.topic_id = url.topic_id>

above

<cfif #isDefined('url.action')# AND url.action NEQ "">
0
 
LelloLelloAuthor Commented:
okay what changes i should do ?  I can create another page no problem...
0
 
micropc1Commented:
actually in  candidate_e.cfm, put...

<cfif structKeyExists(URL, "topic_id")>
<cfset form.topic_id = url.topic_id>
</cfif>

above

<cfif #isDefined('url.action')# AND url.action NEQ "">  (line 10)

and remove the line

<cfset form.topic_id = url.topic_id> (line 15)
0
 
LelloLelloAuthor Commented:
I did a change... now what is the url i should use in my link to go directly to topic1 or topic2

http://127.0.0.1/jp/for/candidate_e.cfm?topic_id=16&etc........... ???

<cfif structKeyExists(URL, "topic_id")>
<cfset form.topic_id = url.topic_id>
</cfif>


<cfif #isDefined('url.action')# AND url.action NEQ "">
	<cfset form.action = url.action>
    <cfset form.sortOptions = url.sortBy>
	<cfset form.candidates = url.candidate_id>
    <cfset form.response_id = url.response_id>
   <!--- <cfset form.topic_id = url.topic_id>--->
    <cfset form.xaction = url.xaction>

    <cfset session.response_id = url.response_id>
    <cfset session.candidates = url.candidate_id>
    
<cfelse>
	<cfparam name="form.action" default="" />
</cfif>

Open in new window

0
 
LelloLelloAuthor Commented:
Perfect... I will have another question tomorrow. keep in touch!

thank you :)
0
 
LelloLelloAuthor Commented:
Thank you All !!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.