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

Passing text field value in url

Explorer ,
Oct 24, 2008 Oct 24, 2008

Copy link to clipboard

Copied

I have a page with several list boxes referencing variable recordsets (bond types, bond purposes, etc.). I have "EDIT" links beside each going to the respective pages that perform those duties. I have named the list boxes (ex. id="Purposes") and I want to pass the value selected in the list boxes to the EDIT pages. When I try to use the link editPurpose.cfm?Purpose_ID=<cfoutput>#Purposes#</cfoutput>, I get the error "Variable PURPOSES is undefined". How do I reference a text field that is not in a form?
TOPICS
Advanced techniques

Views

2.1K

Translate

Translate

Report

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
Explorer ,
Oct 24, 2008 Oct 24, 2008

Copy link to clipboard

Copied

Sorry, I meant "Passing List Box Value in URL". doh!

Votes

Translate

Translate

Report

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 24, 2008 Oct 24, 2008

Copy link to clipboard

Copied

use whatever logic you used to name and give values to your check boxes to produce that variable.

Votes

Translate

Translate

Report

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
Explorer ,
Oct 24, 2008 Oct 24, 2008

Copy link to clipboard

Copied

I tried that first. I tried referencing the recordset that fills in the box, but no matter which value I selected from the list box, it would only pass the first value of the list. That's why I thought I should reference the list box by ID instead of the recordset that fills it out.

Votes

Translate

Translate

Report

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 24, 2008 Oct 24, 2008

Copy link to clipboard

Copied

I'm guessing wildly here, since we have not seen any code.

This sounds like it might be a client problem. Where you have a list
control and you want to submit the value of the list control.

If so, then you are either looking at just making the form method="get"
or doing something with JavaScript.

But without any code and|or a much clearer idea of your requirements I
can not get more specific.

Votes

Translate

Translate

Report

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
Explorer ,
Oct 27, 2008 Oct 27, 2008

Copy link to clipboard

Copied

I'm not using a form, but I may need to go that direction. As I have several different edit pages I would need to go to (a different one per list box), multiple forms with multiple submit buttons may be the way to go.

Votes

Translate

Translate

Report

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
Participant ,
Oct 24, 2008 Oct 24, 2008

Copy link to clipboard

Copied


Hi,

Since the value from the listbox gets selected on client-side (after CF has processed the page on server-side, and sent it to the client), CF will not know which value is currently selected in the listbox.

What you can use on client side, to take the currently selected value and open some page with the value in the URL is to use Javascript.

Have a look at the function below, and google for more info if necessary.

cheers,
fober

<div onclick="window.open('page.cfm?ID='+ document.getElementById('x').value ,'', '');">edit</div>

<select id="x" name="somelistbox">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>

Votes

Translate

Translate

Report

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
Explorer ,
Oct 27, 2008 Oct 27, 2008

Copy link to clipboard

Copied

I'm still having no luck. Here's my function in the header:

<script type="text/javascript">
function GetValue()
{
var Purpose = document.getElementById("Purposes").value;
return (Purpose);
}
</script>

and here's my code in the link:

<td><div align="center"><a href="purposeEdit.cfm?Purpose_ID=getValue()">EDIT</a></div></td>

But I'm getting an error "Invalid data getValue() for CFSQLTYPE CF_SQL_INTEGER". Do I need to surround the function with javascript brackets or something?

Votes

Translate

Translate

Report

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
Participant ,
Oct 27, 2008 Oct 27, 2008

Copy link to clipboard

Copied

window.location.href='sale_1.cfm?Page=1&Shopping='+this.value;

this is the code I used in my list box...+this.value get whatever the value the user pick on the list box and use it in the url.

Hope it helps you

Votes

Translate

Translate

Report

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 27, 2008 Oct 27, 2008

Copy link to clipboard

Copied

You can't reference a javascript function as the value of a url, AKA
get, parameter. Can you? I sure have never seen anything like that and
it does not make sense to me.

I would expect to see something like this....
<a href="purposeEdit.cfm" onClick="GetValue();">EDIT</a>

Then the getValue() function would do something to pass that parameter
on to the next page.

Votes

Translate

Translate

Report

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
Explorer ,
Oct 27, 2008 Oct 27, 2008

Copy link to clipboard

Copied

Screw it. I'll just use multiple forms to point the way, I'm getting nowhere fast with the javascript.

Thanks anyway everyone.

Votes

Translate

Translate

Report

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
Explorer ,
May 21, 2009 May 21, 2009

Copy link to clipboard

Copied

LATEST

I wound up using multiple forms on the same page (one for each list box), and it works great.  Thanks again all.

Votes

Translate

Translate

Report

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
Documentation