Solved

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

Posted on 2012-04-02
13
1,172 Views
Last Modified: 2012-06-11
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
0
Comment
Question by:LelloLello
  • 6
  • 4
  • 2
  • +1
13 Comments
 
LVL 7

Expert Comment

by:micropc1
ID: 37799041
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
 

Author Comment

by:LelloLello
ID: 37799059
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
 
LVL 52

Expert Comment

by:_agx_
ID: 37799083
(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
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 
LVL 4

Assisted Solution

by:TechHelpr08210
TechHelpr08210 earned 50 total points
ID: 37799128
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
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 50 total points
ID: 37799148
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
 

Author Comment

by:LelloLello
ID: 37799185
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
 
LVL 7

Expert Comment

by:micropc1
ID: 37799191
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
 

Author Comment

by:LelloLello
ID: 37799193
okay what changes i should do ?  I can create another page no problem...
0
 
LVL 7

Expert Comment

by:micropc1
ID: 37799198
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
 

Author Comment

by:LelloLello
ID: 37799222
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
 
LVL 7

Accepted Solution

by:
micropc1 earned 400 total points
ID: 37799255
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
 

Author Comment

by:LelloLello
ID: 37799264
Perfect... I will have another question tomorrow. keep in touch!

thank you :)
0
 

Author Closing Comment

by:LelloLello
ID: 37799267
Thank you All !!!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question