0
setting a variable from select option value
Explorer
,
/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/td-p/152925
Sep 23, 2008
Sep 23, 2008
Copy link to clipboard
Copied
I'm having a hard time setting a variable from the value in
my select, option (drop-down box value). Can someone give me some
sample code to do that?
Thanks.
Thanks.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/m-p/152926#M13948
Sep 23, 2008
Sep 23, 2008
Copy link to clipboard
Copied
form.cfm
--------
<form action="action.cfm" method="post">
<select name="myCoolSelect">
<option value="foo" selected="selected">Joe Cool</option>
</select>
<input type="submit">
</form>
action.cfm
----------
<cfoutput>#form.myCoolSelect#</cfoutput>
--------
<form action="action.cfm" method="post">
<select name="myCoolSelect">
<option value="foo" selected="selected">Joe Cool</option>
</select>
<input type="submit">
</form>
action.cfm
----------
<cfoutput>#form.myCoolSelect#</cfoutput>
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/m-p/152927#M13949
Sep 23, 2008
Sep 23, 2008
Copy link to clipboard
Copied
What kind of variable? What's it going to be used for?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
tgoold
AUTHOR
Explorer
,
/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/m-p/152928#M13950
Sep 23, 2008
Sep 23, 2008
Copy link to clipboard
Copied
The option variable will be a URL. I want to use the variable
in my action statement, as in <cfform action=the url from the
select statement.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
tgoold
AUTHOR
Explorer
,
/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/m-p/152929#M13951
Sep 23, 2008
Sep 23, 2008
Copy link to clipboard
Copied
<form name="form3" method="post" action="#dev#">
<select onChange="this.form.submit()" name="dev">
<option value="javascript:void(0)" selected>- Select -</option>
<option value="search-swdev.cfm">Approved Developers List</option>
My question is: How do I get "search-swdev.cfm" set as #dev# so that action will load that URL?
<select onChange="this.form.submit()" name="dev">
<option value="javascript:void(0)" selected>- Select -</option>
<option value="search-swdev.cfm">Approved Developers List</option>
My question is: How do I get "search-swdev.cfm" set as #dev# so that action will load that URL?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/m-p/152936#M13958
Sep 24, 2008
Sep 24, 2008
Copy link to clipboard
Copied
> My question is: How do I get "search-swdev.cfm" set as
#dev# so that action
> will load that URL?
>
Reading this and some of your replies.... I do not think this is a
ColdFusion problem. That looks like you are trying to create a
JavaScript jump list.
I have not done this in a long time since they have fallen out of favor
do to accessibilities issues.
You will need to create a JavaScript function that is called from the
select onChange event. This function will read the value of the
selected option, modify the form action to this value and then submit
the form.
> will load that URL?
>
Reading this and some of your replies.... I do not think this is a
ColdFusion problem. That looks like you are trying to create a
JavaScript jump list.
I have not done this in a long time since they have fallen out of favor
do to accessibilities issues.
You will need to create a JavaScript function that is called from the
select onChange event. This function will read the value of the
selected option, modify the form action to this value and then submit
the form.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/m-p/152938#M13960
Sep 25, 2008
Sep 25, 2008
Copy link to clipboard
Copied
<select onChange="this.form.action =
this.value;this.form.submit()" name="dev">
the above script might work.
the above script might work.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/m-p/152930#M13952
Sep 23, 2008
Sep 23, 2008
Copy link to clipboard
Copied
The simplest way is to submit to a page which reads that form
field and forwards the user to the real page.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
tgoold
AUTHOR
Explorer
,
/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/m-p/152931#M13953
Sep 24, 2008
Sep 24, 2008
Copy link to clipboard
Copied
How do I do that? Don't I still have to know the value of the
option? How do I get that?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/m-p/152932#M13954
Sep 24, 2008
Sep 24, 2008
Copy link to clipboard
Copied
quote:
Originally posted by: tgoold
How do I do that? Don't I still have to know the value of the option? How do I get that?
from the form variables.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
tgoold
AUTHOR
Explorer
,
/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/m-p/152933#M13955
Sep 24, 2008
Sep 24, 2008
Copy link to clipboard
Copied
Is it like form.option.value?
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/m-p/152934#M13956
Sep 24, 2008
Sep 24, 2008
Copy link to clipboard
Copied
quote:
Originally posted by: tgoold
Is it like form.option.value?
No, that is javascript which you can use to see your form field values before you submit your form.
I was referring to form scope variables which you can process with cold fusion after the form is submitted.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
tgoold
AUTHOR
Explorer
,
/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/m-p/152935#M13957
Sep 24, 2008
Sep 24, 2008
Copy link to clipboard
Copied
oh, ok. I'll give it a try. Thanks for your help.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
tgoold
AUTHOR
Explorer
,
/t5/coldfusion-discussions/setting-a-variable-from-select-option-value/m-p/152937#M13959
Sep 24, 2008
Sep 24, 2008
Copy link to clipboard
Copied
Thanks, Ian. I don't think I can do it without JavaScript
either.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

