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,167 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to Popup 37 81
Unexpected HttpURLConnection connection behavior 2 51
Drop down button NAMES disappear 1 41
Hovering effect 9 29
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

760 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now