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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
_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
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

TechHelpr08210Commented:
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_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
micropc1Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LelloLelloAuthor Commented:
Perfect... I will have another question tomorrow. keep in touch!

thank you :)
0
LelloLelloAuthor Commented:
Thank you All !!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.