473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

how to get select label?

lli
Hi Guys,

I built a select in a form. My select is:
print '<SELECT NAME="county">'
print '<OPTION VALUE="000">ALL'
print '<OPTION VALUE="001">AAA'
print '<OPTION VALUE="002">BBB'
print '</SELECT>'

I can get which item value users select. For example users select item
2, I can get its value "001". But now I want to get item label "AAA",
not its value "001". How I can do this. I use python to code.
Any help is appricated.
LLI

Dec 14 '05 #1
8 1964
Il 2005-12-14, ll*@sos.state.tx.us <ll*@sos.state.tx.us> ha scritto:
Hi Guys,

I built a select in a form. My select is:
print '<SELECT NAME="county">'
print '<OPTION VALUE="000">ALL'
print '<OPTION VALUE="001">AAA'
print '<OPTION VALUE="002">BBB'
print '</SELECT>'


Which web technology/framework are you using that requires plains print
an this odd HTML? CGI?

--
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"
Dec 14 '05 #2
lli
Sorry , I forget to say that. I use CGI, HTML and python.

LLI

Dec 14 '05 #3
Il 2005-12-14, ll*@sos.state.tx.us <ll*@sos.state.tx.us> ha scritto:
Sorry , I forget to say that. I use CGI, HTML and python.


Why you need to get the text value, don't you have it when you
create the page?

ps. do you really need CGIs ?
--
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"
Dec 14 '05 #4
lli
I build web application. So I use CGI. I need to show select text in
the html page. Now I can only display select value such as '001'. But I
need to display its text 'AAA'.

LLI

Dec 14 '05 #5
Il 2005-12-14, ll*@sos.state.tx.us <ll*@sos.state.tx.us> ha scritto:
I build web application. So I use CGI. I need to show select text in
the html page. Now I can only display select value such as '001'. But I
need to display its text 'AAA'.


There are tons of way to build web apps in Python and CGI is the last I
rely on. Anyway you can make a dirty trick passing in hidden HTML fields
the text values and match against.
--
Lawrence - http://www.oluyede.org/blog
"Anyone can freely use whatever he wants but the light at the end
of the tunnel for most of his problems is Python"
Dec 14 '05 #6
ll*@sos.state.tx.us wrote:
I built a select in a form. My select is:
print '<SELECT NAME="county">'
print '<OPTION VALUE="000">ALL'
print '<OPTION VALUE="001">AAA'
print '<OPTION VALUE="002">BBB'
print '</SELECT>'

I can get which item value users select. For example users select item
2, I can get its value "001". But now I want to get item label "AAA",
not its value "001". How I can do this. I use python to code.


This is actually a HTML question, not python:

You're doing it almost right except that the option tag should be closed
as always.

<SELECT NAME="county">
<OPTION VALUE="000">ALL</OPTION>
<OPTION VALUE="001">AAA</OPTION>
<OPTION VALUE="002">BBB</OPTION>
</SELECT>

better yet but may not be supported in all browsers (try):

<SELECT NAME="county">
<OPTION VALUE="000" LABEL="ALL"></OPTION>
<OPTION VALUE="001" LABEL="AAA"></OPTION>
<OPTION VALUE="002" LABEL="BBB"></OPTION>
</SELECT>
Dec 14 '05 #7
On Wed, 14 Dec 2005 13:56:24 -0800, lli wrote:
I build web application. So I use CGI. I need to show select text in
the html page. Now I can only display select value such as '001'. But I
need to display its text 'AAA'.

LLI


I'm a Python newbie, so by all means verify this answer with more
experienced folks. But what you're running into is a limitation of
HTML/HTTP/CGI. When your form contains a <SELECT> element, the values that
get passed to the CGI are the VALUE elements. If you want to get, for
example, AAA then you would need to put AAA in the VALUE field.
Dec 15 '05 #8
Dan M <da*@wolf.com> writes:
On Wed, 14 Dec 2005 13:56:24 -0800, lli wrote:
I build web application. So I use CGI. I need to show select text in
the html page. Now I can only display select value such as '001'. But I
need to display its text 'AAA'.

I'm a Python newbie, so by all means verify this answer with more
experienced folks. But what you're running into is a limitation of
HTML/HTTP/CGI. When your form contains a <SELECT> element, the values that
get passed to the CGI are the VALUE elements. If you want to get, for
example, AAA then you would need to put AAA in the VALUE field.


If you leave the VALUE attribute, you'll get the contents of the
OPTION element. This saves having to duplicate the value.

<mike
--
Mike Meyer <mw*@mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
Dec 15 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: JT | last post by:
I have an input form for which I've created a "matrix" for user input. Basically, the user chooses a radio button and then through javascript, a select box is displayed to define a value for that...
4
by: point | last post by:
Hello there... I'm a PHP programmer and starting to learn JS... I have a following problem.... I have 3 select boxes! one is hotel one is destination and one is country... if someone...
0
by: ClarkePeters | last post by:
I don't have any problems with select1 or textarea with my xforms in firefox 1.5.0.9, but I can't seem to get my "select" several choices to work. I need to select zero or more of several choices....
2
by: Thad | last post by:
In the html I have a select option. I am trying to get the result of the selection(u5503_qty*5) to print after some text. I am having a problem grabbing the value of u5503_qty from the html to use...
25
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.